1

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 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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! :)
2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.