Path: csiph.com!usenet.pasdenom.info!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'win32': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'string.': 0.05; 'string': 0.09; 'lawrence': 0.09; 'parsing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'language.': 0.14; 'considers': 0.16; 'eof': 0.16; 'expects': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'syntaxerror:': 0.16; 'unexpected': 0.16; 'subject:python': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'thanks.': 0.20; 'input': 0.22; 'header:User-Agent:1': 0.23; '2.x': 0.24; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'dec': 0.30; 'skip:( 20': 0.30; '"",': 0.31; '13,': 0.31; 'file': 0.32; '(most': 0.33; 'fri,': 0.33; '"the': 0.34; 'there': 0.35; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'dangerous': 0.60; 'our': 0.64; 'provide': 0.64; 'more': 0.64; 'behavior': 0.77; 'amit': 0.84; '2013,': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: input() on python 2.7.5 vs 3.3.2 Date: Thu, 12 Dec 2013 15:04:39 +0000 References: <2ba69b81-99f9-40d6-a337-afb2f892ecff@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-191-126.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386861007 news.xs4all.nl 2847 [2001:888:2000:d::a6]:57977 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61727 On 12/12/2013 14:56, Amit Saha wrote: > On Fri, Dec 13, 2013 at 12:45 AM, wrote: >> Can someone explain? Thanks. >> >> Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> x = input() >> Hello there >>>>> print(x) >> Hello there > > In Python 3, input() considers an input as a string and returns the > input as a string. This is the behavior of raw_input() in Python 2. > >> >> Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> x = input() >> Hello there >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 1 >> Hello there >> ^ >> SyntaxError: unexpected EOF while parsing > > In Python 2, input() expects valid Python as it's input. If you > provide your input as 'Hello there' (a Python string), it won't > complain. > > HTH, > Amit. > 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." -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence