Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Eclipse Carriage Return Workaround

9 views
Skip to first unread message

Steve Holden

unread,
Dec 18, 2009, 10:38:37 AM12/18/09
to pytho...@python.org
I've written a Python 3 course that uses an Eclipse-based teaching
system. The school is telling me that their version of Eclipse/pydev
appears to have an input() function that appends a carriage return
character to the user's input. This makes several things go screwy, as
it's definitely not the way the standalone interpreter works, even on
Windows.

Can anyone think of a simple way work around this issue by overriding
__builtins__.input() with a function that calls input() and then returns
an rstrip()ped version of the input string? I though of setting a
PYTHONSTARTUP environment variable, but that only affects interactive
interpreter instances.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/

Gregory Ewing

unread,
Dec 18, 2009, 7:26:53 PM12/18/09
to
Steve Holden wrote:
>
> Can anyone think of a simple way work around this issue by overriding
> __builtins__.input() with a function that calls input() and then returns
> an rstrip()ped version of the input string? I though of setting a
> PYTHONSTARTUP environment variable, but that only affects interactive
> interpreter instances.

Maybe you could put something in site.py?

--
Greg

Fabio Zadrozny

unread,
Dec 19, 2009, 5:36:51 AM12/19/09
to Steve Holden, pytho...@python.org
On Fri, Dec 18, 2009 at 1:38 PM, Steve Holden <st...@holdenweb.com> wrote:
> I've written a Python 3 course that uses an Eclipse-based teaching
> system. The school is telling me that their version of Eclipse/pydev
> appears to have an input() function that appends a carriage return
> character to the user's input. This makes several things go screwy, as
> it's definitely not the way the standalone interpreter works, even on
> Windows.
>
> Can anyone think of a simple way work around this issue by overriding
> __builtins__.input() with a function that calls input() and then returns
> an rstrip()ped version of the input string? I though of setting a
> PYTHONSTARTUP environment variable, but that only affects interactive
> interpreter instances.

In my opinion that's a python bug (because it should be able to remove
the \r\n and not only \n).

Anyway, Pydev also had that problem and it was fixed by having a
custom sitecustomize.py:

See: http://github.com/aptana/Pydev/tree/master/plugins/org.python.pydev/PySrc/pydev_sitecustomize/

It just has to added to the pythonpath before the run (and it'll
remove itself and call the default later on) -- the only catch is that
it has to be on a folder called "pydev_sitecustomize" -- you can
probably change the code if you don't want to follow that.

It'll fix input(), raw_input() and will also fix encoding problems
when writing non ASCII to the console (you may set a
'PYDEV_CONSOLE_ENCODING' in the environment or let it try to find a
default on) -- should be compatible with python 2 or 3.

Cheers,

Fabio

Fabio Zadrozny

unread,
Dec 19, 2009, 5:39:19 AM12/19/09
to Steve Holden, pytho...@python.org

I just noted that you said they are already using pydev -- maybe it's
an old version? Or maybe you're doing a custom launcher that overrides
the usual pythonpath and for some reason is not passing the
pydev_sitecustomize folder?

Cheers,

Fabio

0 new messages