By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,675 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,675 IT Pros & Developers. It's quick & easy.

Strange behavior of the Eclipse embedded console

P: n/a
i've faced with some strangeness while executing this sample:

choice = raw_input("your choice: ")
print len(choice)

when i run this sample in my eclipse console with CPython and print
Yes, i have this output
4 #trailing \t is the fourth element

but when i use command line method
python sample.py
i have the correct length = 3

i'm curious now, can anyone explain that?

Mar 20 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 20 อมา, 14:31, hellt <Dodin.Ro...@gmail.comwrote:
i've faced with some strangeness while executing this sample:

choice = raw_input("your choice: ")
print len(choice)

when i run this sample in my eclipse console with CPython and print
Yes, i have this output
4 #trailing \t is the fourth element

but when i use command line method
python sample.py
i have the correct length = 3

i'm curious now, can anyone explain that?

just took a look into PyDEV-FAQ.

"The eclipse console is not an exact copy of a shell... one of the
changes is that when you press <ENTERin a shell, it may give you a
\r, \n or \r\n as an end-line char, depending on your platform. Python
does not expect this -- from the docs it says that it will remove the
last \n (checked in version 2.4), but, in some platforms that will
leave a \r there. This means that the raw_input() should usually be
used as raw_input().replace('\r', ''), and input() should be changed
for: eval(raw_input().replace('\r', ''))."

Mar 20 '08 #2

P: n/a
On Mar 20, 9:09*am, hellt <Dodin.Ro...@gmail.comwrote:
"The eclipse console is not an exact copy of a shell... one of the
changes is that when you press <ENTERin a shell, it may give you a
\r, \n or \r\n as an end-line char, depending on your platform. Python
does not expect this -- from the docs it says that it will remove the
last \n (checked in version 2.4), but, in some platforms that will
leave a \r there. This means that the raw_input() should usually be
used as raw_input().replace('\r', ''), and input() should be changed
for: eval(raw_input().replace('\r', ''))."
While I do love Eclipse as a Python code editor, interactive debugger,
front-end to SVN / Trac, and for many other things... it is
unfortunately terrible as an interactive console.

But then again, despite being a long time Emacs user I never did
anything complex inside Emacs' shell / terminal emulator, instead
preferring a 'real' console using xterm or rxvt or konsole or what
have you.

By the way, so far the only text editing feature from Emacs I am
missing in Eclipse is the ability to reformat line endings - i.e., M-x
fill-paragraph-or-region

regards
Preston
Mar 20 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.