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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'anyway.': 0.05; 'hiding': 0.09; 'lawrence': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'imo,': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'coding': 0.22; 'cc:addr:python.org': 0.22; '2.x': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'dec': 0.30; 'evaluation': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; '13,': 0.31; 'probably': 0.32; 'fri,': 0.33; '"the': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'behind': 0.37; 'rather': 0.38; 'dangerous': 0.60; 'name': 0.63; 'more': 0.64; 'to:none': 0.92; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=KT9q1kJ4wU3ffMRrMtkJtOnx5klyjpJO8hfYNuMduqc=; b=jYKL4AV9UpDZ/25HkOzn7Z1xtt4vkYWlTsvr6Gzq//ZySv9w4FQBsbuyEBYWpsrdCN FaKvWpq0ySj1cFG8ihdi9trfv+khGexYwnnWUEAHk7qnQyFtVirhKtHkGuHpKUMKh47S oysiycSFxP0cDmk3fskZb+GB0FGPdw4BFCSBUenIF47LV+PQ9sD3u/bLTZdCG42Q4hMM +8pubjv4H6Iu0c2DAJlcVhlw47QlfeUiaRNeePr2en/yQQDzrF0j2K5X0JcexCsSI/Bx 8LTVC6tzbkbZgx6d2DCb+hDpJa4Ze7Bsh4eH/eXAbz3UROPCyym99WkhTLuYvG+ibp/R PjFg==
MIME-Version 1.0
X-Received by 10.68.236.133 with SMTP id uu5mr13036484pbc.153.1386861472345; Thu, 12 Dec 2013 07:17:52 -0800 (PST)
In-Reply-To <l8cja6$uts$2@ger.gmane.org>
References <2ba69b81-99f9-40d6-a337-afb2f892ecff@googlegroups.com> <CANODV3mj84V9K8Tyvj65pYzbuuKvxOOfAoyQhNAGH9E84kPQ0g@mail.gmail.com> <l8cja6$uts$2@ger.gmane.org>
Date Fri, 13 Dec 2013 02:17:52 +1100
Subject Re: input() on python 2.7.5 vs 3.3.2
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4002.1386861476.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1386861476 news.xs4all.nl 2879 [2001:888:2000:d::a6]:36631
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:61729

Show key headers only | 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