Re: python2 input

Discussion in 'Python' started by Chris Angelico, May 3, 2013.

  1. On Fri, May 3, 2013 at 5:16 PM, dabaichi <> wrote:
    > Hello guys:
    > Do you have found that the built-in input() function is dangerous.
    > Here is my code(python 2.x only):
    >
    > a = input("Input anything:")
    > print("go here")
    >
    > If I input:
    > sys.exit(0)
    > print("go here") will not be execute, and the script will exit.


    Yeah, that's kinda discovered. In Python 2, you should be using
    raw_input() for that kind of thing. In Python 3, raw_input() was
    renamed to input(), and if you want the semantics of Py2 input(), it's
    eval(input()), which makes it obvious what's going on.

    ChrisA
    Chris Angelico, May 3, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xavier
    Replies:
    0
    Views:
    416
    Xavier
    Aug 6, 2003
  2. Skip Montanaro
    Replies:
    1
    Views:
    432
    Thomas Heller
    Aug 7, 2003
  3. snacktime
    Replies:
    13
    Views:
    560
    Dan Sommers
    Feb 22, 2005
  4. Uwe Mayer

    changing from python2.3 to python2.4

    Uwe Mayer, Apr 8, 2005, in forum: Python
    Replies:
    1
    Views:
    301
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 9, 2005
  5. Ksenia Marasanova
    Replies:
    2
    Views:
    352
    Mike Meyer
    Nov 17, 2005
Loading...

Share This Page