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


Groups > comp.lang.python > #82543

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'syntax': 0.04; 'subject:Python': 0.06; 'lawrence': 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; '"from': 0.16; '__future__': 0.16; 'advice,': 0.16; 'bracket': 0.16; 'nameerror:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'soup': 0.16; 'subject: \n ': 0.16; 'subject:object': 0.16; 'syntaxerror:': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'input': 0.22; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'defined': 0.27; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'skip:p 30': 0.29; "skip:' 10": 0.31; '"",': 0.31; '3.x': 0.31; 'subject:that': 0.31; 'file': 0.32; '(most': 0.33; 'subject:with': 0.35; "didn't": 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'skip:n 30': 0.60; 'skip:o 30': 0.61; "you're": 0.61; 'name': 0.63; 're:': 0.63; 'our': 0.64; 'more': 0.64; 'dear': 0.65; 'charset:windows-1252': 0.65; 'here': 0.66; 'invalid': 0.68; 'subject:made': 0.84; '2013,': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Python console rejects an object reference, having made an object with that reference as its name in previous line
Date Mon, 15 Dec 2014 02:47:31 +0000
References <01937423-e700-4825-a502-568dcb2d5324@googlegroups.com> <41c32aed-315a-43df-9dc6-380d0ecc3425@googlegroups.com> <548e4837$0$13012$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-147-26-7.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
In-Reply-To <548e4837$0$13012$c3e8da3$5496439d@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16967.1418611665.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418611665 news.xs4all.nl 2888 [2001:888:2000:d::a6]:49054
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82543

Show key headers only | View raw


On 15/12/2014 02:32, Chris Roy-Smith wrote:
> On 15/12/14 10:21, Simon Evans wrote:
>> Dear Jussi, and Billy
>> I have changed the input in accordance with your advice, re:
>> ------------------------------------------------------------------------------
>>
>> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit
>> (Intel)] on win
>
> here the user is using python 2.7.6
>
>
>> 32
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> from bs4 import BeautifulSoup
>>>>> with open("ecologicalpyramid.html","r") as ecological_pyramid:
>> ...      soup = next(ecological_pyramid,"lxml")
>> ...      producer_entries = soup.find("ul")
>> ...      print(producer_entries.li.div.string)
>> ... print(producer_entries.li.div.string)
>>    File "<stdin>", line 5
>>      print(producer_entries.li.div.string)
>>          ^
>
> and here he uses a python 3.x print syntax which triggers the following
> error message
>
>> SyntaxError: invalid syntax
>>>>> print (producer_entries.li.div.string)
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> NameError: name 'producer_entries' is not defined
>

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")?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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