Input() in Python3

Chris Angelico rosuav at gmail.com
Fri Apr 22 02:49:19 EDT 2011


On Fri, Apr 22, 2011 at 4:22 PM, harrismh777 <harrismh777 at charter.net> wrote:
> now we get this for input():
>
>   raw_input("prompt>") --> string

I would have to say that the 2.x behaviour of input() is a mistake
that's being corrected in 3.x. With a simple name like input(), it
should do something simple and straightforward - not eval() the
expression.

> to:        a = eval(input("enter a number > "))

Uhhhh.... NO. NO NO NO. What if someone enters "os.exit()" as their
number? You shouldn't eval() unchecked user input!

Chris Angelico



More information about the Python-list mailing list