Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed8.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:text': 0.04; 'indicated': 0.07; "subject:' ": 0.07; 'subject:code': 0.07; 'client:': 0.09; 'nameerror:': 0.09; 'subject:Getting': 0.09; 'subject:Why': 0.09; 'typed': 0.09; 'python': 0.10; 'subject: \n ': 0.15; '"expected': 0.16; 'error"': 0.16; 'soup': 0.16; 'subject:Started': 0.16; 'wrote:': 0.16; 'subject:page': 0.18; '>>>': 0.20; '2015': 0.20; 'suggested': 0.20; '"",': 0.22; '12th': 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; 'least': 0.27; '+0200,': 0.27; 'preceding': 0.29; 'whitespace': 0.29; 'character': 0.29; 'code': 0.30; 'skip:s 30': 0.31; 'traceback': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'nov': 0.35; 'something': 0.35; 'expected': 0.35; 'should': 0.36; '(and': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'means': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'more': 0.63; 'dear': 0.67; 'jul': 0.72; 'sunday': 0.72; '2013,': 0.91; 'albert': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=36igi8YTjJYmLt/1lwY65VogrfqERaYIImVngawrL6M=; b=DX4N+6EEXTxVpTITVIZo7/i/rtHgqpzjtngbXvgi0/eccyE3hn4Svm3FPAzLT0Zmhs TJski0/Bl6lEI4/iY47zPC0UQI80RQR2FLoODEcj6sXFGiMkAwtqDxVQ8yKx73xA7dEl 78TiaNaSKqjxQaIX6lg3JQYGW4mboeRYp8U9iCd+xNTTEkExaxc7mkZu9fT+SeLM31+R OKzmglfkrCRS3/yVtI6/65MUSCcIfXJfeCsslyjtJ6a97/F2V1WXlPUh/DfJcG33UfRA SLozEozcfb0jt+RadoySlno9cyLBGj8ylKNjIlfE3qUMWasmBz2eo0QRo2iGwTeR0ve7 jqdg== X-Received: by 10.180.79.162 with SMTP id k2mr16305939wix.46.1436726061324; Sun, 12 Jul 2015 11:34:21 -0700 (PDT) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: python-list@python.org Subject: Re: Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? References: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> Date: Sun, 12 Jul 2015 20:34:18 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Albert Visser" In-Reply-To: <1e75fe53-743b-4432-8b4e-6897b3d54956@googlegroups.com> User-Agent: Opera Mail/12.16 (Linux) 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: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436726068 news.xs4all.nl 2935 [2001:888:2000:d::a6]:40068 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93742 On Sun, 12 Jul 2015 19:33:17 +0200, 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" "Expected an indented block" means that the indicated line should have started with at least one whitespace character more than the preceding line. >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f,"lxml") should have been something like >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f: ... soup = BeautifulSoup(f,"lxml") -- Vriendelijke groeten / Kind regards, Albert Visser Using Opera's mail client: http://www.opera.com/mail/