Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!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; 'subject:text': 0.04; 'from:addr:yahoo.co.uk': 0.05; 'list?': 0.07; "subject:' ": 0.07; 'subject:code': 0.07; 'nameerror:': 0.09; 'open()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Getting': 0.09; 'subject:Why': 0.09; 'typed': 0.09; 'python': 0.10; 'suggest': 0.15; 'subject: \n ': 0.15; 'error"': 0.16; 'frankly': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'soup': 0.16; 'subject:Started': 0.16; 'url:tutor': 0.16; 'wrote:': 0.16; 'subject:page': 0.18; 'language': 0.19; '>>>': 0.20; 'suggested': 0.20; '"",': 0.22; '12th': 0.22; 'lawrence': 0.22; 'trying': 0.22; 'code,': 0.23; 'defined': 0.23; 'bit': 0.23; 'second': 0.24; 'import': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'comfortable': 0.27; '100000': 0.29; 'url:mailman': 0.30; 'code': 0.30; 'skip:s 30': 0.31; 'language.': 0.32; 'run': 0.33; 'url:python': 0.33; 'doubt': 0.33; 'traceback': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'nov': 0.35; 'path': 0.35; 'expected': 0.35; 'url:org': 0.36; 'possible.': 0.36; '(and': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'mailing': 0.38; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'mark': 0.40; 'subject:with': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'more': 0.63; 'our': 0.64; 'tutor': 0.66; 'dear': 0.67; 'day': 0.67; 'sunday': 0.72; 'marines': 0.84; 'plants': 0.84; 'pythonistas,': 0.84; '2013,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? Date: Sun, 12 Jul 2015 19:23:05 +0100 References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-92-24-220-121.ppp.as43234.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 61 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436725403 news.xs4all.nl 2922 [2001:888:2000:d::a6]:36590 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93741 On 12/07/2015 18:33, Simon Evans wrote: > > Dear Peter Otten, > I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got: > ---------------------------------------------------------------------------- > 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("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: > ... soup = BeautifulSoup(f,"lxml") > File "", line 2 > soup = BeautifulSoup(f,"lxml") > ^ > IndentationError: expected an indented block >>>> soup = BeautifulSoup(f,"lxml") > Traceback (most recent call last): > File "", line 1, in > NameError: name 'f' is not defined >>>> > ---------------------------------------------------------------------------- > The first time I typed in the second line, I got the > "Indentation error" > the second time I typed in exactly the same code, I got the: > "NameError:name 'f' is not defined" > You can tell that to the marines :) >>> with open("ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f) ... producer_entries = soup.find("ul") ... producer_entries ...
  • plants
    100000
  • algae
    100000
>>> Can I suggest that you slow down. It strikes me that you're trying to run a marathon a day for a year before you can even walk. For example is the file path in your call to open() correct? Frankly I very much doubt it, although it is possible. Perhaps you'd be more comfortable on the tutor mailing list? If so see https://mail.python.org/mailman/listinfo/tutor or gmane.comp.python.tutor. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence