Linebreak problem on the interactive interpreter Win2k
Tim Peters
tim.one at comcast.net
Fri Feb 20 13:37:00 EST 2004
[Jonas Galvez]
> A few days ago I posted about a problem I was having on Win2k,
> regarding a SyntaxError error on the interactive interpreter to
> anything I typed. The thread is located here: tinyurl.com/2kk7b
>
> I've mode some progress on this. I noticed that the problem in
> fact lies on the line break. If I place a # on the end of the line,
> Python has no problem interpreting it:
>
> C:\>python
> Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on
win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> print "This works" #
> This works
> >>>
>
> However:
>
> >>> print "This doesn't work"
> File "<stdin>", line 1
> print "This doesn't work"
> ^
> SyntaxError: invalid syntax
> >>>
>
> The problem is that Python is not interpreting "\r\n" correctly:
>
> >>> import sys; sys.last_value.text #
> 'print "This doesn\'t work"\r\n'
> >>>
>
> Can I change this anyhow?
You cannot, but you shouldn't need to. At least thousands of people use a
DOS-box Python shell under Win2K (for example, me) without any problem. So
there's something unique about the way your Win2K is set up (unique == I
don't recall anyone reporting this before, and Python has run on Windows for
more than a decade).
Maybe IDLE will work for you (you already have it -- look in your Python 2.3
Start menu). That's generally a lot nicer than using a DOS-box shell
anyway.
BTW, I would *expect* what you're seeing if (and only if) you have an
environment variable set with name PYTHONUNBUFFERED (same as Python's -u
option). That can't be used with interactive mode on Windows.
More information about the Python-list
mailing list