Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3846

Re: Input() in Python3

References <I89sp.39115$yp3.5013@newsfe09.iad>
Date 2011-04-22 16:49 +1000
Subject Re: Input() in Python3
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.731.1303454967.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Apr 22, 2011 at 4:22 PM, harrismh777 <harrismh777@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Input() in Python3 harrismh777 <harrismh777@charter.net> - 2011-04-22 01:22 -0500
  Re: Input() in Python3 Chris Angelico <rosuav@gmail.com> - 2011-04-22 16:49 +1000
  Re: Input() in Python3 Chris Angelico <rosuav@gmail.com> - 2011-04-22 16:50 +1000
  Re: Input() in Python3 Chris Rebert <clp2@rebertia.com> - 2011-04-22 00:46 -0700
    Re: Input() in Python3 harrismh777 <harrismh777@charter.net> - 2011-04-23 20:03 -0500
  Re: Input() in Python3 Westley Martínez <anikom15@gmail.com> - 2011-04-22 06:52 -0700
    Re: Input() in Python3 Mel <mwilson@the-wire.com> - 2011-04-22 10:08 -0400
      Re: Input() in Python3 Chris Angelico <rosuav@gmail.com> - 2011-04-23 06:25 +1000
        Re: Input() in Python3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-22 23:55 +0000
          Re: Input() in Python3 Chris Angelico <rosuav@gmail.com> - 2011-04-23 10:07 +1000
      Re: Input() in Python3 Westley Martínez <anikom15@gmail.com> - 2011-04-23 12:33 -0700
        Re: Input() in Python3 Mel <mwilson@the-wire.com> - 2011-04-25 12:50 -0400

csiph-web