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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'string.': 0.04; '2.x': 0.05; "shouldn't": 0.07; 'pm,': 0.11; 'exception': 0.12; 'wrote:': 0.14; '"))': 0.16; 'expression.': 0.16; 'floats': 0.16; 'subject:() ': 0.16; 'subject:Python3': 0.16; 'header:In-Reply- To:1': 0.22; 'convert': 0.22; 'right,': 0.22; 'chris': 0.27; 'raise': 0.29; 'string': 0.29; 'fri,': 0.29; 'number,': 0.29; "can't": 0.31; 'to:addr:python-list': 0.32; 'someone': 0.33; 'from:charset:iso-8859-1': 0.33; 'header:User-Agent:1': 0.35; 'getting': 0.36; 'however': 0.37; 'should': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'user': 0.38; 'no.': 0.38; 'to:addr:python.org': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'simple': 0.60; '2011': 0.62; 'received:74.125.83': 0.69; 'enters': 0.73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=UAIUVwAA1QBcooSprn9XEifD/riC/n0mjZodz6T4N7Y=; b=iiREiU63ObwC9gTkRfTYh2guQTC+rVTEhVs8KW3sTUpLYKovzcFHgUWZLVKeDCUcwW 1Zh4bsaEpo+OA44g/uD9UDwjbkRuA6ktybQsJsU0LVzIMrjUULr1rrOpkV91v/G0Ctyw nTKf4D9RtZZXdehhg85JWivkqz8oZyOmF67I0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; b=FybTlIzOXDxZngmIjvV8pm7LqRmcrJ7TOfnMlIpmzfuSFP584Fd4bPzrJ9oUh6lUwY Nj0KoSF/BKHo0Jr1PIbV2gLKHVzhSfPUrN32i6Nhx7HMC72etPsf0U04Mw6RBbSz/KHA zddm6gXkKvCKgFqRccyV/wQKEp0s0r7WOSJY4= Date: Fri, 22 Apr 2011 06:52:20 -0700 From: Westley =?iso-8859-1?Q?Mart=EDnez?= To: python-list@python.org Subject: Re: Input() in Python3 References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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: 23 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303480346 news.xs4all.nl 41102 [::ffff:82.94.164.166]:59757 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3868 On Fri, Apr 22, 2011 at 04:49:19PM +1000, Chris Angelico wrote: > On Fri, Apr 22, 2011 at 4:22 PM, harrismh777 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 Right, there's no way to check you're getting a number, however using: a = int(input('enter a number > ')) # use float() for floats will raise an exception if it can't convert the string.