[Pythonmac-SIG] one fallout of cr/lf code
Magladry, Stephen
stephenm@humongous.com
Fri, 18 Oct 2002 12:05:05 -0700
It is nice to be able to run PC Python code unchanged thanks to the code
change made to handle cr/lf within the Mac Python code. I have run into one
problem through. The cr/lf is view as two separate lines. The following
code,
--test.py from a pc----
import sys <cr><lf>
sys.blah<cr><lf>
--test.py from a pc----
returns the following error:
File "test.py", line 3 in ?
AttributeError: 'module' object has no attribute 'blah'
Okay I can deal with doubling of the line number, that's not much of a
problem. The real problem is with line continuations.
--test2.py from a pc----
x = x\ <cr><lf>
+1<cr><lf>
--test2.py from a pc----
This code is not able to execute. The line continuation "works" on the <lf>.
The <cr> is seen as a new line. Now without a continuation, Mac Python isn't
able to correctly process it. I can "fix" my problems my doing the
following.
--fixedTest2.py from a pc----
x = (x <cr><lf>
+1)<cr><lf>
--fixedTest2.py from a pc----
Since an expression gets started with the "(", line continuation come for
free. This is fine and dandy for cross platform code that I own and work
with. It might be more of a problem with Python code one would get from some
PC user, though.
Don't know if we can do anything about this. If not, consider this as a FYI
for those people working in a cross platform environment.
Sincerely,
Stephen Magladry