views:

70

answers:

2

Hello, I am writing a simple commandline script that uses raw_input, but it doesn't seem to work.

This code:

print "Hello!"
raw_input("")

Produces this error:

Traceback (most recent call last):
 File "<pyshell#6>", line 1, in <module>
raw_input("")
TypeError: 'str' object is not callable

I have never encountered this error before, and couldn't find anything on Google. I am using Python 2.6 on Windows 7.

+2  A: 

Works fine as presented, e.g. in an interpreter prompt in any Python 2 version:

>>> print "Hello!"
Hello!
>>> raw_input("")
bah
'bah'
>>> 

where bah is what I typed after the code you gave in response to the empty-prompt;-).

The only explanation for the error you mention is that you've performed other code before this, which included binding identifier raw_input to a string.

Alex Martelli
+1  A: 

It appears you are using something called pyshell. There is likely a bug there in that shell itself. Try just using vanilla bash.

carl
I think it was some sort of bug. I closed all the processes associated with the interpreter and editor, then ran it again and it worked just fine. Thank you everyone for your suggestions though! :)
Zachary Brown