Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news.astraweb.com!border2.a.newsrouter.astraweb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'causing': 0.04; 'syntax': 0.04; 'subject:Python': 0.06; 'extent': 0.07; 'skip:o 50': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'windows': 0.15; 'ahead,': 0.16; 'issue?': 0.16; 'nameerror:': 0.16; 'programmers,': 0.16; 'soup': 0.16; 'subject: \n ': 0.16; 'subject:object': 0.16; 'syntaxerror:': 0.16; "would've": 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; 'input': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'getting': 0.31; '"",': 0.31; 'subject:that': 0.31; 'file': 0.32; 'quite': 0.32; 'url:python': 0.33; '(most': 0.33; 'proceed': 0.33; 'maybe': 0.34; 'subject:with': 0.35; "can't": 0.35; 'point.': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'url:org': 0.36; 'wrong': 0.37; 'skip:& 10': 0.38; 'nov': 0.38; 'previous': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'skip:b 40': 0.39; 'url:mail': 0.40; 'hope': 0.61; 'gone': 0.61; 'skip:o 30': 0.61; 'name': 0.63; 'more': 0.64; 'dear': 0.65; 'beautiful': 0.68; 'invalid': 0.68; '(according': 0.84; 'console,': 0.84; 'plants': 0.84; 'subject:made': 0.84; 'to:addr:yahoo.co.uk': 0.84; 'yours': 0.88; '2013,': 0.91 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:to :cc:content-type; bh=jW9RRHhl0DEWZJplZNuNVfMuA/+iQt89/PXipb0/uyo=; b=xhg5DCzKkW9Z3InAZqfmlLaFxWoPR4D+WOKWXQBPpuZlmTRdNqxYkr6R02TAstIeqF uKzp5Y1OrYBFOZ/acMJK5UmaUqpkiKFA0zSeDhbt0bGYXlDWBxGxwtzVFoeHkOOc8PET l2fymbEcLi5W/RuOf32p0wD5PAbrItpQuZj/B2F4j8uHouhZ+jZq00sk3ms7EL0aI0sV ioF/VVNfWiQXWMXn5rR7J0FDYEYZ1M6H064xiwqwJYt3qBGN4ZLAj8mCPXMG5QMLPx2v Iqliar1VMsAC9EjC+G6FZsE4SM2HHV/bN8OJkcdx2STeQ6R92pXCW8dqHPmMBd8Ao6Dm KbEA== MIME-Version: 1.0 X-Received: by 10.152.10.40 with SMTP id f8mr26697186lab.52.1418575409131; Sun, 14 Dec 2014 08:43:29 -0800 (PST) In-Reply-To: <01937423-e700-4825-a502-568dcb2d5324@googlegroups.com> References: <01937423-e700-4825-a502-568dcb2d5324@googlegroups.com> Date: Sun, 14 Dec 2014 10:43:28 -0600 Subject: Re: Python console rejects an object reference, having made an object with that reference as its name in previous line From: Billy Earney To: Simon Evans Content-Type: multipart/alternative; boundary=001a1132ed64593515050a2fd368 X-Mailman-Approved-At: Sun, 14 Dec 2014 23:00:27 +0100 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: 124 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418594429 news.xs4all.nl 2875 [2001:888:2000:d::a6]:43506 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82527 --001a1132ed64593515050a2fd368 Content-Type: text/plain; charset=UTF-8 It looks like the last line (producer_entries...) is not indented at the same extent as the previous line. Maybe this is causing the issue? On Sun, Dec 14, 2014 at 10:15 AM, Simon Evans wrote: > > Dear Python programmers, > Having input the line of code in text: > cd Soup > to the Windows console, and having put the file 'EcologicalPyramid.html' > into the Directory 'Soup', on the C drive, in accordance with instructions > I input the following code to the Python console, as given on page 30 of > 'Getting Started with Beautiful Soup': > > ---------------------------------------------------------------------------- > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] > on win > 32 > Type "help", "copyright", "credits" or "license" for more information. > >>> from bs4 import BeautifulSoup > >>> with open("ecologicalpyramid.html","r") as ecological_pyramid: > ... soup = BeautifulSoup(ecological_pyramid,"lxml") > ... producer_entries = soup.find("ul") > > ^ > SyntaxError: invalid syntax > >>> producer_entries = soup.find("ul") > Traceback (most recent call last): > File "", line 1, in > NameError: name 'soup' is not defined > >>> > ^ > > ---------------------------------------------------------------------------- > so I cannot proceed with the next line withh would 've been : > > ---------------------------------------------------------------------------- > print(producer_entries.li.div.string) > > ---------------------------------------------------------------------------- > which would've given (according to the book) the output: > --------------------------------------------------------------------------- > plants > > Maybe that is getting a bit far ahead, but I can't quite see where I have > gone wrong - 'soup' has been defined as an object made of file > 'EcologicalPyramid.html > > I hope you can help me on this point. > Yours > Simon > -- > https://mail.python.org/mailman/listinfo/python-list > --001a1132ed64593515050a2fd368 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
It looks like the last line (producer_entries...) is not i= ndented at the same extent as the previous line.=C2=A0 Maybe this is causin= g the issue?

On Sun, Dec 14, 2014 at 10:15 AM, Simon Evans <musicalhacksa= w@yahoo.co.uk> wrote:
Dear Pyt= hon programmers,
Having input the line of code in text:
cd Soup
to the Windows console, and having put the file 'EcologicalPyramid.html= ' into the Directory 'Soup', on the C drive, in accordance with= instructions I input the following code to the Python console, as given on= page 30 of 'Getting Started with Beautiful Soup':
---------------------------------------------------------------------------= -
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] o= n win
32
Type "help", "copyright", "credits" or "= license" for more information.
>>> from bs4 import BeautifulSoup
>>> with open("ecologicalpyramid.html","r") as= ecological_pyramid:
...=C2=A0 =C2=A0 =C2=A0 soup =3D BeautifulSoup(ecological_pyramid,"lxm= l")
... producer_entries =3D soup.find("ul")

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^
SyntaxError: invalid syntax
>>> producer_entries =3D soup.find("ul")
Traceback (most recent call last):
=C2=A0 File "<stdin>", line 1, in <module>
NameError: name 'soup' is not defined
>>>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^
---------------------------------------------------------------------------= -
so I cannot proceed with the next line withh would 've been :
---------------------------------------------------------------------------= -
print(producer_entries.li.div.string)
---------------------------------------------------------------------------= -
which would've given (according to the book) the output:
---------------------------------------------------------------------------=
plants

Maybe that is getting a bit far ahead, but I can't quite see where I ha= ve gone wrong - 'soup' has been defined as an object made of file &= #39;EcologicalPyramid.html

I hope you can help me on this point.
Yours
Simon
--
https://mail.python.org/mailman/listinfo/python-list
--001a1132ed64593515050a2fd368--