Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82547

Re: Python console rejects an object reference, having made an object with that reference as its name in previous line

References <01937423-e700-4825-a502-568dcb2d5324@googlegroups.com> <41c32aed-315a-43df-9dc6-380d0ecc3425@googlegroups.com> <548e4837$0$13012$c3e8da3$5496439d@news.astraweb.com> <m6li43$spf$1@ger.gmane.org> <548E7129.1000807@gmail.com>
Date 2014-12-15 16:32 +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 <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16970.1418621552.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Dec 15, 2014 at 4:27 PM, Michael Torrie <torriem@gmail.com> 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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Python console rejects an object reference, having made an object with that reference as its name in previous line Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-12-14 08:15 -0800
  Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Ned Batchelder <ned@nedbatchelder.com> - 2014-12-14 11:36 -0500
  Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-12-14 10:37 -0800
    Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-14 20:51 +0200
  Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Billy Earney <billy.earney@gmail.com> - 2014-12-14 10:43 -0600
  Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-12-14 15:21 -0800
    Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-15 11:36 +1100
    Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Chris Roy-Smith <chris_roysmith@internode.on.net> - 2014-12-15 13:32 +1100
      Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Chris Angelico <rosuav@gmail.com> - 2014-12-15 13:42 +1100
      Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-15 02:47 +0000
      Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Michael Torrie <torriem@gmail.com> - 2014-12-14 22:27 -0700
      Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Chris Angelico <rosuav@gmail.com> - 2014-12-15 16:32 +1100
      Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Michael Torrie <torriem@gmail.com> - 2014-12-14 22:38 -0700
      Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-12-14 23:51 -0600
      Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Chris Angelico <rosuav@gmail.com> - 2014-12-15 16:52 +1100
  Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-12-18 08:19 -0800
    Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Michael Torrie <torriem@gmail.com> - 2014-12-18 09:35 -0700
  Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Simon Evans <musicalhacksaw@yahoo.co.uk> - 2015-01-04 04:49 -0800
    Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-04 13:11 +0000
    Re: Python console rejects an object reference, having made an object with that reference as its name in previous line Dave Angel <davea@davea.name> - 2015-01-04 09:14 -0500

csiph-web