views:

86

answers:

2

EDIT-4

I've gotten my sitecustomize.py to execute, but it tosses up an error. Here's the code for it.

The error is:

Error in sitecustomize; set PYTHONVERBOSE for traceback:
RuntimeError: maximum recursion depth exceeded while calling a Python object

I'm not terribly advanced with Python yet, so I figured I'd comment out only the lines I did not think Iwould need. No encoding issues are showing up, so I just commented out lines 23-104, but that didn't help either.

EDIT-3

I also happened to have 2.5.1 installed, so I compiled another script with that.

print 'This will test carriage returns on Windows with PyDev on Eclipse Helios'
print'Type something:',
test = raw_input()
print('You entered the following ascii values:')
for c in test:
    print(str(ord(c)))

This ran fine, and resulted in

This will test carriage returns on Windows with PyDev on Eclipse Helios
Type something: g
You entered the following ascii values:
103

So this is possibly a Python3 thing only? I know it's not the interpreter, because I'm able to run it in command prompt just fine. What gives?

EDIT-2

Just tested with Helios, still having the same problem. Here's my test program:

print('This will test carriage returns on Windows with PyDev on Eclipse Helios.')
print('Type something:', end='')
test = input()
print('You entered the following ascii values:')
for c in test:
    print(str(ord(c)))

And here's the output when I type 'g' and press Enter:

This will test carriage returns on Windows with PyDev on Eclipse Helios.
Type something:g
You entered the following ascii values:
103
13

In the grand scheme of things, it's a small issue. I could use input().rstrip() and it works. But the workaround shouldn't even be necessary. I'm typing twice as much as I should need to in a language that I'm using because it's concise and pretty.

EDIT-1

This is Eclipse 3.5. Unfortunately that's the latest version that's been approved for use at work. I'm going to try 3.6 at home to see if that's any different, but I wouldn't be able to use it anyway.


(original question)

I've been learning some basic Python, and decided to go with PyDev since it supported Python 3 as well as having all the nice code snippet and auto complete features.

However, I'm running into that darned carriage return issue on Windows.

My searches always lead me back to this mailing list: http://www.mail-archive.com/[email protected]/msg269758.html

So I have grabbed the sitecustomize.py file, tried to include it in the Python path for my configured interpreter, as well as my project, but to no avail.

Has anybody else managed to work through this? Or maybe knows how to get the new sitecustomize.py to actually execute so it can override input() and raw_input()?

I know I could always make a short module with my own replacement input() function, but I'd really like to fix the problem at its root. Aptana acknowledges the issue ( http://pydev.org/faq.html#why_raw_input_input_does_not_work_correctly ) but offers no solution. Thanks in advance for your help.

A: 

Found out some more things about sitecustomize.py and how it relates to site.py.

I don't know how to add my own sitecustomize.py to PYTHONPATH for execution only in a PyDev project, so I just stuck it in ${Python31dir}\Libs\site-packages. The module runs now, but generates errors.

bearcdp
+1  A: 

Figured out a hack to make it work locally to my Python installation. In \Lib\site-packages\ make a script called "sitecustomize.py", and put this code in it:

original_input = builtins.input

def input(prompt=''):  
    return original_input(prompt).rstrip('\r')

input.__doc__ = original_input.__doc__

builtins.input = input

I don't know anything about the side effects of this, or what sort of error checking I should be doing, but it works if you're using PyDev on Windows to write scripts with Python3.

bearcdp