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

Michael Torrie torriem at gmail.com
Thu Dec 18 11:35:45 EST 2014


On 12/18/2014 09:19 AM, Simon Evans wrote:
> @Steven D'Aprano,
> I input the following to Python 2.7, which got the following:- 
> ----------------------------------------------------------------------------
>>>> from bs4 import BeautifulSoup
>>>> with open("ecologicalpyramid.html","r") as ecological_pyramid:
> ...      soup= next(ecological_pyramid,"lxml")
> ...      producer_entries = soup.find("ul")
> ...
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> IOError: [Errno 2] No such file or directory: 'ecologicalpyramid.html'
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the problem here. And it's not a syntax error.

> - I kept to your instructions to input the 'Enter' after the fourth
> line and then before the fifth line, ie between the indented block and
> the unindented one, which as above, doesn't give me a chance to actually
>input the fifth line. If I do it both ways, ie: pressing enter after the
>fourth and before the fifth or just pressing enter after the fourth and
>then after the fifth line of input, which again it won't actually let me
>input because before I do, I still get an error return.

Did you read the actual error message? In this case it's not a syntax
error.  Do you understand what the error actually is and why it's
happening?  (IE did your read what the error was? Hint. It's not the
same as your previous errors.)




More information about the Python-list mailing list