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. -- https://mail.python.org/mailman/listinfo/python-list