Eclipse Carriage Return Workaround

Fabio Zadrozny fabiofz at gmail.com
Sat Dec 19 05:39:19 EST 2009


On Sat, Dec 19, 2009 at 8:36 AM, Fabio Zadrozny <fabiofz at gmail.com> wrote:
> On Fri, Dec 18, 2009 at 1:38 PM, Steve Holden <steve at 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.
>

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



More information about the Python-list mailing list