Python Tip

Every Python book and website tutorial recommends the following command for prompting the user for input:


But I have found that this command is buggy and unreliable.

Specifically, I wrote a long, complex code that had several raw_input() commands.

The code ran successfully in Spyder. But I received the following error when I ran it in console mode: “Readline internal error” plus some other cryptic messages about, hook_wrapper_23 & NoneType.

The error occurred when the code executed the second raw_input().

After hours of struggle, I found that I could use the following command instead:


sys.stdin.readline() works in both Sypder and external command-line mode.

sys.stdin.readline() is a superior alternative.

Yes, my perceptions are colored by my inexperience, but I like commands that reliably work straight out-of-the-box.  So I will stick with sys.stdin.readline().

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s