Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'syntax': 0.04; 'that?': 0.05; 'subject:Python': 0.06; 'imported': 0.09; 'interpreted': 0.09; 'lawrence': 0.09; 'parsed': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"from': 0.16; '__future__': 0.16; 'bracket': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'redundant': 0.16; 'statement.': 0.16; 'subject: \n ': 0.16; 'subject:object': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; 'import': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'mon,': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; '15,': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'michael': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'subject:that': 0.31; 'call.': 0.33; 'subject:with': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'keyword': 0.36; "didn't": 0.36; 'pm,': 0.38; 'expression': 0.60; "you're": 0.61; 'more': 0.64; 'future,': 0.83; '2014,': 0.84; 'subject:made': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=KMNFccP3RykkvILjZGO1jB36+QdfG81j446QXiWRzjg=; b=k3HE7VeOF8tQsgN8sZQ3g3bSaDBHOy5icGykJHmAchUP89rOLHUU42vYHeOfQeo3Fn wC0jTVmPCFEW9UOh2k43FfuiRTbRsdjMbSnoRy7vbkYWIUZqusfXwqDr/aY7SGUuLtqp JVdaUyVUYnxySEx8hQGULnSjfA5/Ce9fkGvnlqTTcf2/8lDhCjPBOtlp5dBeoHhoFA5Q ynvaPMRNce6ULAsCkE8WKzOnn8ClLdB5QRL3Imipv7Fs3MN5B87jry6mPvI54rADaomm +qsjuW1wou6cfYP0gHkkwfGfLERXVMUVzhwoY9+SMujR+1TVmAC++o32BGceUJxYxrB4 y8YA== MIME-Version: 1.0 X-Received: by 10.107.7.94 with SMTP id 91mr26406360ioh.27.1418621542867; Sun, 14 Dec 2014 21:32:22 -0800 (PST) In-Reply-To: <548E7129.1000807@gmail.com> References: <01937423-e700-4825-a502-568dcb2d5324@googlegroups.com> <41c32aed-315a-43df-9dc6-380d0ecc3425@googlegroups.com> <548e4837$0$13012$c3e8da3$5496439d@news.astraweb.com> <548E7129.1000807@gmail.com> Date: Mon, 15 Dec 2014 16:32:22 +1100 Subject: Re: Python console rejects an object reference, having made an object with that reference as its name in previous line From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418621552 news.xs4all.nl 2957 [2001:888:2000:d::a6]:35779 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82547 On Mon, Dec 15, 2014 at 4:27 PM, Michael Torrie wrote: > On 12/14/2014 07:47 PM, Mark Lawrence wrote: >> I didn't realise that Python was so smart. It can indicate a syntax >> error at the final 't' in print before it gets to the opening bracket >> that is required for the print function in Python 3 (and Python 2 if >> you're using "from __future__ import print_function")? > > Not really. Python2 just interprets "print (value)" as an expression to > the print statement. It's like saying "a=(value)" and then "print a". > Redundant but works. However "print(value)" is interpreted as a > function call, and if you haven't imported it from future, it will error > out on Python2. Did you actually test that? Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> print("hello") hello Since print is a keyword when not imported from future, there's no way for print(value) to be parsed as a function call. ChrisA