Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'yeah,': 0.09; 'python': 0.11; 'execute,': 0.16; 'exit.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'input:': 0.16; 'renamed': 0.16; 'semantics': 0.16; 'sys.exit(0)': 0.16; 'wrote:': 0.18; '2.x': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'fri,': 0.33; 'received:google.com': 0.35; 'should': 0.36; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'kind': 0.63; 'here': 0.66; 'obvious': 0.74; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=gzeYrX5vOmYS/WNvnTOPYHzrQviCTiN7HDeghI8wb44=; b=pq+wdxBgMkpfBMVah+AfgWTC8Tl7IWrIxAcw2M7//5EFFIXqojznNlt0ZYtGctj7a3 KQCflqkItEOuOhwHwIAwwnH2mOhzrWEMsLVpwy90Fy1S661EcTVXI08CWTMzfuypiC4t latfDLFdazKF2DERZF6p8UNFfvV4vKag/z4dUudhHT0AW5yR7Igx3k4vIevP56QI7MEn cZoUxOmrJ3svFtt+g1k8QAGAbg6vama3HUgSi7ul2g99l3TKXIrZaXkFIR3CKKKRj+4p va+eODJxNODyfu6ZCaEbbCrsK5CSJh2sJyouUI3/hWpimok+OEQ7cV09GPZZgLKuxosU 7jXA== MIME-Version: 1.0 X-Received: by 10.52.120.83 with SMTP id la19mr1059842vdb.58.1367566319331; Fri, 03 May 2013 00:31:59 -0700 (PDT) In-Reply-To: References: Date: Fri, 3 May 2013 17:31:59 +1000 Subject: Re: python2 input From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367566322 news.xs4all.nl 15887 [2001:888:2000:d::a6]:40447 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44658 On Fri, May 3, 2013 at 5:16 PM, dabaichi wrote: > Hello guys: > Do you have found that the built-in input() function is dangerous. > Here is my code(python 2.x only): > > a = input("Input anything:") > print("go here") > > If I input: > sys.exit(0) > print("go here") will not be execute, and the script will exit. Yeah, that's kinda discovered. In Python 2, you should be using raw_input() for that kind of thing. In Python 3, raw_input() was renamed to input(), and if you want the semantics of Py2 input(), it's eval(input()), which makes it obvious what's going on. ChrisA