On 15/12/2014 02:32, Chris Roy-Smith wrote:
On 15/12/14 10:21, Simon Evans wrote:
Dear Jussi, and Billy
I have changed the input in accordance with your advice, re:
------------------------------------------------------------------------------

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit
(Intel)] on win

here the user is using python 2.7.6


32
Type "help", "copyright", "credits" or "license" for more information.
from bs4 import BeautifulSoup
with open("ecologicalpyramid.html","r") as ecological_pyramid:
...      soup = next(ecological_pyramid,"lxml")
...      producer_entries = soup.find("ul")
...      print(producer_entries.li.div.string)
... print(producer_entries.li.div.string)
   File "<stdin>", line 5
     print(producer_entries.li.div.string)
         ^

and here he uses a python 3.x print syntax which triggers the following
error message

SyntaxError: invalid syntax
print (producer_entries.li.div.string)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
NameError: name 'producer_entries' is not defined


I didn't realise that Python was so smart. It can indicate a syntax error at the final 't' in print before it gets to the opening bracket that is required for the print function in Python 3 (and Python 2 if you're using "from __future__ import print_function")?

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to