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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'sys': 0.04; 'int': 0.05; 'ignored': 0.07; "shouldn't": 0.07; 'python': 0.07; 'recursion': 0.09; '(0)': 0.11; '>>>': 0.12; 'exception': 0.12; 'wrote:': 0.14; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '[gcc': 0.16; 'floats': 0.16; 'linux2': 0.16; 'mart\xednez': 0.16; 'subject:() ': 0.16; 'subject:Python3': 0.16; 'what?': 0.16; 'traceback': 0.16; '(most': 0.16; 'header:In-Reply- To:1': 0.22; 'convert': 0.22; 'right,': 0.22; 'last):': 0.23; 'calling': 0.25; 'received:209.85.212': 0.25; 'chris': 0.27; 'object': 0.27; "doesn't": 0.28; 'raise': 0.29; 'error': 0.29; 'fri,': 0.29; 'number,': 0.29; 'depth': 0.31; "can't": 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'someone': 0.33; 'from:charset:iso-8859-1': 0.33; 'file': 0.35; 'header:User- Agent:1': 0.35; '"",': 0.35; 'getting': 0.36; 'however': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'user': 0.38; 'but': 0.38; 'no.': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; '2011': 0.62; 'maximum': 0.62; 'skip:> 20': 0.68; 'enters': 0.73; 'exceeded': 0.86 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=F7jnyWUnhV7YOLTPjMxEfVwYbRakeyb2/fFWyhiRI7I=; b=ZHs9iw1xLWaTv32cIybeafMjQiZdalgw6moHqj/n6kSvJKFLfyexj9R+CtJUhimsnn b+NeyRMeP4p406K07iR5xpwP0/hPboJ8tiriZxaVMLb6znlt1hDkNJkAkVdL8TQEfUNS WA1hMMAeV5KadNIS6/MZaqKj+jzXtjmJz37dE= 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=UhrFSMdAVddvjKbySAb22NA9RRvaUA/LkX/dZje+cFCGGMt6HkZIYxMzxv42Q64k43 F/Yp9tJ2taGUwyBlQ3sLlJcIIBYYAz7KfG+bfMXmqEwlBK+LyHeEloPOXHJhDtOAS1PR KzpXi8+s9nWMO1ATzzY3xZsCdK/aYw8R2CXtI= Date: Sat, 23 Apr 2011 12:33:47 -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: 53 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303587241 news.xs4all.nl 81483 [::ffff:82.94.164.166]:42006 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3922 On Fri, Apr 22, 2011 at 10:08:20AM -0400, Mel wrote: > Westley Martínez wrote: > > On Fri, Apr 22, 2011 at 04:49:19PM +1000, Chris Angelico wrote: > > >> 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. > > But sys.exit() doesn't return a string. My fave is > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import sys > >>> a = int (input ('enter a number >')) > enter a number >sys.setrecursionlimit(1) > Exception RuntimeError: 'maximum recursion depth exceeded while calling a > Python object' in ignored > Exception RuntimeError: 'maximum recursion depth exceeded while calling a > Python object' in ignored > Error in sys.excepthook: > RuntimeError: maximum recursion depth exceeded > > Original exception was: > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exceeded while calling a Python object > >>> int (0) > Exception RuntimeError: 'maximum recursion depth exceeded while calling a > Python object' in ignored > Exception RuntimeError: 'maximum recursion depth exceeded while calling a > Python object' in ignored > Error in sys.excepthook: > RuntimeError: maximum recursion depth exceeded > > Original exception was: > Traceback (most recent call last): > File "", line 1, in > RuntimeError: maximum recursion depth exceeded while calling a Python object > >>> > > > Mel. > What?