Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'string.': 0.05; 'string': 0.09; 'parsing': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'considers': 0.16; 'eof': 0.16; 'expects': 0.16; 'syntaxerror:': 0.16; 'unexpected': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'thanks.': 0.20; 'input': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; '"",': 0.31; '13,': 0.31; '>>>>': 0.31; 'file': 0.32; '(most': 0.33; 'fri,': 0.33; 'received:google.com': 0.35; 'there': 0.35; 'recent': 0.39; 'provide': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'url:me': 0.69; 'behavior': 0.77; '2013,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=aw67Kj05QaZZslvwXGjpDEhBkxqBDDLXG4KKdte7OwI=; b=XQv1UrXrJgaumkkIzc0RREUXAwh9PEnmOs4XO9icpogNLFq8F0PV/jezYqKB++XaEf WYnmFOrVwMsCICxYEUNhOkx1preAPVIx1lFpy3TtDWPGRcIcw9ZzvL+yhrGF7XmS3Heb Qj8rEgc9FgH/SAyCpkXY0Q/CVAVw1gr4LBj1XIqS5y/wc8qbCpy7byRdutpGKf48T/rj JKEwFQnlSek9bXOuGy/lrNqfVgAYPJNkl2DRYkuVfkQ6L+HiME5yRFLYi2Qwsr11z8l2 gfMf3RQl7jNeL1p5itYEww/sa8FzaGL//Ir5gqtoJiFCS85ce8EBy7juguaaLAuEw39f dqwA== X-Received: by 10.68.173.132 with SMTP id bk4mr2524614pbc.169.1386860209879; Thu, 12 Dec 2013 06:56:49 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <2ba69b81-99f9-40d6-a337-afb2f892ecff@googlegroups.com> References: <2ba69b81-99f9-40d6-a337-afb2f892ecff@googlegroups.com> From: Amit Saha Date: Fri, 13 Dec 2013 00:56:09 +1000 Subject: Re: input() on python 2.7.5 vs 3.3.2 To: stephen.boulet@gmail.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386860217 news.xs4all.nl 2919 [2001:888:2000:d::a6]:47381 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61723 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. -- http://echorand.me