According to the wPIA book (e.g, page 262), function arguments within
parentheses can be spread over multiple lines for readability. However,
whenever I try to do this, python complains. For example,
Traceback (most recent call last):
File "eikos.py", line 13, in ?
from variablePage import modVar
File "/data1/eikos/variablePage.py", line 549
"WARNING: Deleting this variable will also delete
^
SyntaxError: EOL while scanning single-quoted string
I thought that with Python, anything within parentheses, brackets, or
braces could be split over multiple lines, even without a line-terminating
backslash. Is this not the case?
Rich
···
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
According to the wPIA book (e.g, page 262), function arguments within
parentheses can be spread over multiple lines for readability. However,
whenever I try to do this, python complains. For example,
Traceback (most recent call last):
File "eikos.py", line 13, in ?
from variablePage import modVar
File "/data1/eikos/variablePage.py", line 549
"WARNING: Deleting this variable will also delete
^
SyntaxError: EOL while scanning single-quoted string
I thought that with Python, anything within parentheses, brackets, or
braces could be split over multiple lines, even without a line-terminating
backslash. Is this not the case?
This is not the case. If you want to do this with string literals, you
can do it like this:
("one"
... "two"
... "three"
... )
'onetwothree'
Adjacent string literals are concatenated (like in C), and the parens
allow you to dispense with escaping the newline.
···
On 10/2/07, Rich Shepard <rshepard@appl-ecosys.com> wrote:
It looks to me like you broke in the middle of a quoted string -- you cant do that.
You can't do:
("a long string
that is even longer"
)
(unless it is triple quoted)
You can do:
>>> ("a long string"
... "that is even longer"
... )
'a long stringthat is even longer'
>>>
i.e. two strings that are next to each-other will be merged
If that's not your issue, post the section of code that's barfing...
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
OK. Now I understand. It works with string literals but not with a mix of
strings and non-string parameters.
Thanks for clarifying,
Rich
···
On Tue, 2 Oct 2007, Chris Mellon wrote:
This is not the case. If you want to do this with string literals, you
can do it like this:
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
OK. Now I understand. It works with string literals but not with a mix of
strings and non-string parameters.
huh?
it works fine with a mix:
>>> def f(*args): print args
...
>>> f(45,
... "this",
... "that",
... "A long string"
... " and the rest of it",
... 5.65,
... {4:"four", 5:"five"}
... )
(45, 'this', 'that', 'A long string and the rest of it', 5.6500000000000004, {4: 'four', 5: 'five'})
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
I see what I missed before: I can break the sequence of token within the
parentheses as long as each string literal has no newline within it. I knew
that, and should have seen that's what I was doing.
Rich
···
On Tue, 2 Oct 2007, Christopher Barker wrote:
huh?
it works fine with a mix:
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863