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

Simon Evans musicalhacksaw at yahoo.co.uk
Thu Dec 18 11:19:51 EST 2014


@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'
>>>
----------------------------------------------------------------------------
- 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.



More information about the Python-list mailing list