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


Groups > comp.lang.python > #61729

Re: input() on python 2.7.5 vs 3.3.2

References <2ba69b81-99f9-40d6-a337-afb2f892ecff@googlegroups.com> <CANODV3mj84V9K8Tyvj65pYzbuuKvxOOfAoyQhNAGH9E84kPQ0g@mail.gmail.com> <l8cja6$uts$2@ger.gmane.org>
Date 2013-12-13 02:17 +1100
Subject Re: input() on python 2.7.5 vs 3.3.2
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4002.1386861476.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Dec 13, 2013 at 2:04 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> I much prefer Chris Angelico's response "The input() function in Python 2.x
> is a very dangerous one - it's equivalent to eval(input()) in Python 3."

Just to clarify: If you *want* eval, then you know you want it, and
you are (or should be) aware of its dangers. The problem, imo, is
hiding something as powerful and dangerous as code evaluation behind
the innocuous name "input". If I were coding a Python 2.x REPL, I
would probably write eval(raw_input()) rather than input(), just for
clarity.

But I'm more likely to just code for Python 3 anyway. :)

ChrisA

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


Thread

input() on python 2.7.5 vs 3.3.2 stephen.boulet@gmail.com - 2013-12-12 06:45 -0800
  Re: input() on python 2.7.5 vs 3.3.2 Chris Angelico <rosuav@gmail.com> - 2013-12-13 01:53 +1100
  Re: input() on python 2.7.5 vs 3.3.2 Amit Saha <amitsaha.in@gmail.com> - 2013-12-13 00:56 +1000
  Re: input() on python 2.7.5 vs 3.3.2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-12 15:04 +0000
  Re: input() on python 2.7.5 vs 3.3.2 Chris Angelico <rosuav@gmail.com> - 2013-12-13 02:17 +1100

csiph-web