Strange behavior of the Eclipse embedded console

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hellt

    Strange behavior of the Eclipse embedded console

    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?

  • hellt

    #2
    Re: Strange behavior of the Eclipse embedded console

    On 20 ÍÁÒ, 14:31, hellt <Dodin.Ro...@gm ail.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().rep lace('\r', ''), and input() should be changed
    for: eval(raw_input( ).replace('\r', ''))."



    Comment

    • Preston  Landers

      #3
      Re: Strange behavior of the Eclipse embedded console

      On Mar 20, 9:09 am, hellt <Dodin.Ro...@gm ail.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().rep lace('\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

      Comment

      Working...