Re: plpython function problem workaround
От | Marco Colombo |
---|---|
Тема | Re: plpython function problem workaround |
Дата | |
Msg-id | Pine.LNX.4.61.0503151638400.20758@Megathlon.ESI обсуждение исходный текст |
Ответ на | Re: plpython function problem workaround (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-general |
On Tue, 15 Mar 2005, Tom Lane wrote: > "Sim Zacks" <sim@compulab.co.il> writes: >> I've been looking at the possibility of having a planned CR in the source >> code and I don't see a case where it would happen. > > Does python actually disallow newlines in string literals? That is > > x = 'foo > bar' > > Whether you think this is good style is not the question --- is it > allowed by the language? You can with triple-quoting and by escaping it with backslash. The following code, admitedly ugly, is valid python: a = 'a\ bc' print a b = '''a bc''' print b and produces: abc a bc as output. \<newline> in any non raw literal is allowed and ignored, while a bare <newline> in a triple-quoted string literal is allowed and retained. Moreover, this is not an execise of bad style only. It's customary to write docstrings as multiline triple-quoted string literals: def afunction(a, b, c): """This is a function. Its arguments are: a - first argument b - second argument c - third argument. It does ans returns nothing. """ pass It's more or less the recommended way to document a function (or class or module or whatever). See PEP 257 for more examples: http://www.python.org/peps/pep-0257.html So, to answer to your question, newlines are more than allowed in string literals. .TM. -- ____/ ____/ / / / / Marco Colombo ___/ ___ / / Technical Manager / / / ESI s.r.l. _____/ _____/ _/ Colombo@ESI.it
В списке pgsql-general по дате отправления: