Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2.x': 0.05; 'changes:': 0.07; 'pep': 0.07; 'python': 0.07; '21,': 0.09; '3.x': 0.09; 'scripts': 0.10; 'pm,': 0.11; 'received:74.125.82.174': 0.12; 'received:mail-wy0-f174.google.com': 0.12; 'wrote:': 0.14; '"))': 0.16; 'changed,': 0.16; 'devs': 0.16; 'enlighten': 0.16; 'replaced.': 0.16; 'sense...': 0.16; 'simultaneous': 0.16; 'subject:() ': 0.16; 'subject:Python3': 0.16; 'trivially': 0.16; 'whining': 0.16; 'url:blog': 0.18; 'stuff': 0.18; 'please?': 0.19; 'wondering': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'interface': 0.20; 'code': 0.22; 'header:In- Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'thu,': 0.22; 'once.': 0.23; 'uses.': 0.23; 'fix': 0.24; 'example': 0.24; 'equivalent': 0.26; 'correct': 0.26; "i'm": 0.26; 'chris': 0.27; 'skip:b 20': 0.27; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.28; 'string': 0.29; 'problem': 0.29; 'discussed': 0.29; 'changes': 0.29; 'cc:addr:python.org': 0.31; 'porting': 0.31; 'another': 0.32; 'agree': 0.32; 'skip:e 20': 0.33; 'someone': 0.33; 'bit': 0.33; 'break': 0.33; 'fairly': 0.33; "isn't": 0.34; 'using': 0.34; 'skip:" 10': 0.34; 'apply': 0.34; 'change': 0.34; 'got': 0.34; 'difference': 0.35; 'summary': 0.35; 'there': 0.35; 'causing': 0.35; 'correctly': 0.35; 'quite': 0.36; 'missing': 0.36; 'think': 0.36; 'problems': 0.37; 'should': 0.37; 'run': 0.37; 'apr': 0.38; 'for?': 0.38; 'proposed': 0.38; 'received:google.com': 0.38; 'user': 0.38; 'but': 0.38; 'pretty': 0.38; 'so,': 0.38; 'used': 0.38; 'unless': 0.38; 'errors': 0.39; 'could': 0.39; 'where': 0.39; 'behavior': 0.40; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'removal': 0.60; 'discover': 0.60; 'best': 0.60; '2011': 0.62; 'here.': 0.68; 'discovered': 0.71; 'anything,': 0.73; 'thankful': 0.73; 'to:addr:charter.net': 0.84; 'misuse': 0.91; 'named.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=IervRfAzVbTcR9yW3mNcqzu/DKKPH3iHJGqERLulIsw=; b=UbfTrwtfmR8JmYLnbHk+frt708TSv1qcXTDMm6pu/u0Aiwuccx1otlWIsGMmVcH26C 78n2+kW3Nb/mkUQqDgy/10/UPhTN/u6Qyh2aCZG0Lc77MIKy4EF6UqU4ZXDLxE+dq5Pk eX2nIJinbKxa6ARF2HDsyIHZrVL5SK2fOCiq0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=KhIrt3QTZnLikk0TpoR4PCiTPsjw7fSrozqUAkqR5jzYNeZaFRLTSov9mDqOldL/aT fUqt/6Dn2zMwb0Pvr1da6IbJ+I6Z+LILPvDxOWkDdKmprtpyLscdJ81sXNT3IBZmGzvd KwGnZH47XeP1OElEycv8GV7BNxL8d+vyTr/vA= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Fri, 22 Apr 2011 00:46:17 -0700 X-Google-Sender-Auth: W037zg-m3ddn31YTLaw1U_jocZo Subject: Re: Input() in Python3 From: Chris Rebert To: harrismh777 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 69 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303458379 news.xs4all.nl 41110 [::ffff:82.94.164.166]:34829 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3850 On Thu, Apr 21, 2011 at 11:22 PM, harrismh777 wro= te: > My interactive scripts are giving errors on the input(). I discovered > another fairly significant change in Python3, as discussed in PEP 3111. > > I was a little flabbergasted to discover that input() was proposed to be > removed 'totally' from 3000. Of course I agree with PEP 3111 and am thank= ful > that input() is still a built-in. =C2=A0doh. Well, it pretty much *was* totally removed; it was prone to misuse and had very few legitimate uses. It's just that raw_input() also got renamed simultaneously. What were you using it for? There are often much better alternatives. > The problem is that the behavior was significantly changed, again, causin= g > existing code to break un-necessarily. Python 3 has many "unnecessary" backwards-incompatible changes; the Python devs have made this abundantly clear and one should be aware of this before going into Python 3. And again, I don't think a "behavior change" is the best way to conceptualize this, although from a user perspective, there indeed isn't much difference between a behavior change and a simultaneous removal and renaming. > So, input() used to be equivalent to: > > =C2=A0 eval(raw_input("prompt>")) --> value > > > now we get this for input(): > > > =C2=A0 raw_input("prompt>") --> string > > > I'm not whining or anything, just wondering why? Could someone enlighten = me > please? > > Anyway, it looks like the best fix for 2.x --> 3.x =C2=A0code changes: > > change: =C2=A0 =C2=A0a =3D input("enter a number > ") > > to: =C2=A0 =C2=A0 =C2=A0 =C2=A0a =3D eval(input("enter a number > ")) Did you run your scripts through the 2to3 converter tool? This is one of the many changes it can apply automatically. > Again, this is just another example where leaving the advertised interfac= e > alone would have made more sense... unless of course, I'm missing somethi= ng > important here. input() was rarely used correctly and is quite trivially replaced. raw_input() was used much more frequently, but was a bit awkwardly named. Python 3 made use of its backwards-incompatible status to rectify both of these problems at once. Writing correct code will be now easier for newbies. If you're porting stuff to Python 3, using 2to3 and reading the summary of changes from 2.x are absolute necessities. Cheers, Chris -- http://blog.rebertia.com