[Edu-sig] The fate of raw_input() in Python 3000

Andre Roberge andre.roberge at gmail.com
Tue Sep 5 02:45:11 CEST 2006

The following is something I have been pondering for quite a while now
and am wondering what other people on this list think.

According to PEP 3100
(http://www.python.org/dev/peps/pep-3100/ )
raw_input()  [as well as input()] is recommended for removal from the
built-in namespace, to be replaced by sys.stdin.readline().

While I don't think anyone can argue that this removal makes a major
difference for Python as a programming language, I believe it makes a
significant difference for using Python as a learning language, adding
a non-trivial barrier to learning.

Consider the following fake sessions at the interpreter prompt, where
I use extra parentheses to turn print as a function (as is also
proposed in Python 3000) - these parentheses can of course be used
with today's Python.

# First ever program
>>> print("Hello world!")
Hello world!

# More complicated example from the first interactive session using
today's version
>>> name = raw_input("Enter your name: ")
Enter your name: Andre
>>> print("Hello " + name + "!")
Hello Andre!

# More or less the same example using the proposed changes.
>>> import sys
>>> print("Enter your name: ")
Enter your name:
>>> name = sys.stdin.readline()
<-- Andre
>>> print("Hello " + name + "!")
Hello Andre!

To explain the above *simple* program to a beginner, we'd need:
1. to introduce the import statement
2. to introduce the dot notation (something Kirby would be happy with ;-)

Furthermore, the flow is not the same as with today's raw_input().

I don't like it.

While I totally agree with the proposed removal of input()  [anything
using eval() in a hidden way is *bad*], my preference would be to keep
raw_input()'s functionality, perhaps renaming it to user_input() or



More information about the Edu-sig mailing list