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


Groups > comp.lang.python > #82522

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

From Jussi Piitulainen <jpiitula@ling.helsinki.fi>
Newsgroups comp.lang.python
Subject Re: Python console rejects an object reference, having made an object with that reference as its name in previous line
Date 2014-12-14 20:51 +0200
Organization A noiseless patient Spider
Message-ID <qot388ixdxu.fsf@ruuvi.it.helsinki.fi> (permalink)
References <01937423-e700-4825-a502-568dcb2d5324@googlegroups.com> <e5791b9a-9a60-41b6-b8c6-c92c2cc23246@googlegroups.com>

Show all headers | View raw


Simon Evans writes:

> I had another attempt at inputting the code perhaps with the right
> indentation, I still get an error return, but not one that indicates
> that the code has not been read, as you suggested. re:-
> ----------------------------------------------------------------------
> 
> 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")
>   File "<stdin>", line 3
>     producer_entries = soup.find("ul")
>                    ^
> SyntaxError: invalid syntax

It should look like this, except I'm using built-in functions to get a
single line from a file I happened to have around, and naming it beef
instead of soup:

Python 2.7.3 (default, Sep 26 2013, 16:38:10) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> with open('let.scm') as whatever:
...    beef = next(whatever)
... 
>>> beef
'(define-syntax lets ;let-values, attempt to mod\n'
>>> 

Note the line with only "..." on it? That's where I pressed enter to
let the interpreter know that I had written all the code I wanted it
to handle at that point. I was rewarded with (1) no error message, (2)
a new prompt, where I entered, er, the four letters b e e f and then
pressed enter, and the interpreter printed the first line of my file
for me.

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