f



Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ?

Dear Programmers, 
Thank you for your advice regarding giving the console a current address in the code for it to access the html file. 

The console seems to accept the code to that extent, but when I input the two lines of code intended to access the location of a required word, the console rejects it re :

AttributeError:'NoneType' object has no attribute 'li' 

However the document 'EcologicalPyramid.html' does contain the words 'li' and 'ul', in its text. I am not sure as to how the input is arranged to output 'plants' which is also in the documents text, but that is the word the code is meant to elicit. 

I enclose the pertinent code as input and output from the console, and the html code for the document 'EcologicalPyramid.html'

Thank you in advance for your help. 

---------------------------------------------------------------------
>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as ecological_pyramid:
soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html","lxml")
.... producer_entries = soup.find("ul")
  File "<stdin>", line 2
    producer_entries = soup.find("ul")
                   ^
SyntaxError: invalid syntax
>>> producer_entries = soup.find("ul")
>>> print (producer_entries.li.div.string)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'li'
----------------------------------------------------------------------
prin<html>
<body>
<div class="ecopyramid">
<ul id= "producers">
<li class="producers">
<li class="producerlist">
<div class="name">plants</div>
<div class="number">100000</div>
</li>
<li class="producerlist">
<div class="name">algae</div>
<div class="number">100000</div>
</li>
</ul>
<ul id ="primaryconsumers">
<li class="primaryconsumerlist">
<div class="name">deer</div>
<div class-"number">1000</div>
</li
<li class="primaryconsumerlist">
<div class="name">deer</div>
<div class="number">1000</div>
</li>
<li class="primaryconsumerlist">
<div class="name">rabbit</div>
<div class="number">2000</div>
</li>
</ul>
<ul id="secondaryconsumers">
<li class="secondary consumerlist">
<div class="name">fox</div>
<div class="number">100</div>
</li>
<li class=secondaryconsumerlist">
<div class="name">bear</div>
<div class="number">100</div>
</li>
</ul>
<ul id="tertiaryconsumers">
<li class="tertiaryconsumerslist">
<div class="name">lion</div>
<div class="number">80</div>
</li>
<li class="tertiaryconsumerlist">
<div class="name">tiger</div>
<div class="number">50</div>
</li>
</ul>
</body>
</html>
0
Simon
7/11/2015 10:17:41 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

19 Replies
974 Views

Similar Articles

[PageSpeed] 56

On 11/07/2015 23:17, Simon Evans wrote:
> Dear Programmers,
> Thank you for your advice regarding giving the console a current address in the code for it to access the html file.
>
> The console seems to accept the code to that extent, but when I input the two lines of code intended to access the location of a required word, the console rejects it re :
>
> AttributeError:'NoneType' object has no attribute 'li'
>
> However the document 'EcologicalPyramid.html' does contain the words 'li' and 'ul', in its text. I am not sure as to how the input is arranged to output 'plants' which is also in the documents text, but that is the word the code is meant to elicit.
>
> I enclose the pertinent code as input and output from the console, and the html code for the document 'EcologicalPyramid.html'
>
> Thank you in advance for your help.
>
> ---------------------------------------------------------------------
>>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as ecological_pyramid:
> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html","lxml")

Beautiful Soup takes a string or a file handle so as it's good  practise 
to use the "with open" construct this should do it:-

soup = BeautifulSoup(ecological_pyramid,"lxml")

but do you actually need the "lxml", with the simple parsing I've done 
in the past I've never used it?

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

Mark Lawrence

0
Mark
7/11/2015 11:06:46 PM
Dear Mark Lawrence, thank you for your advice.=20
I take it that I use the input you suggest for the line :

soup =3D BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html",lxml")

seeing as I have to give the file's full address I therefore have to modify=
 your :

soup =3D BeautifulSoup(ecological_pyramid,"lxml")

to :

soup =3D BeautifulSoup("C:\Beautiful Soup\ecological_pyramid," "lxml")

otherwise I get :


>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as ecological_=
pyramid:
>>> soup =3D BeautifulSoup(ecological_pyramid,"lxml")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'ecological_pyramid' is not defined


so anyway with the input therefore as:

>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as ecological_=
pyramid:=20
>>> soup =3D BeautifulSoup("C:\Beautiful Soup\ecological_pyramid,","lxml")
>>> producer_entries =3D soup.find("ul")
>>> print(producer_entries.li.div.string)

I still get the following output from the console:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'li'
>>>

As is probably evident, what is the problem Python has with finding the req=
uired html code within the 'ecologicalpyramid' html file, or more specifica=
lly why does it respond that the html file has no such attribute as 'li' ?
Incidentally I have installed all the xml, lxml, html, and html5 TreeBuilde=
rs/ Parsers. I am using lxml as that is the format specified in the text.=
=20

I may as well quote the text on the page in question in 'Getting Started wi=
th Beautiful Soup':

'Since producers come as the first entry for the <ul>tag, we can use the fi=
nd() method, which normally searches fo ronly the first occurrance of a par=
ticular tag in a BeautifulSoup object. We store this in producer_entries. T=
he next line prints the name of the first producer. From the previous HTML =
diagram we can understand that the first producer is stored inside the firs=
t <div> tag of the first <li> tag that immediately follows the first <ul> t=
ag , as shown inthe following code:=20

<ul id =3D "producers">
<li class=3D "producerlist">
<div class=3D "name">plants</div>
<div class=3D"name">100000</div>
</li>
</ul>

So after running the preceding code, we will get plants, which is the first=
 producer, as the output.'

(page 30)
0
Simon
7/12/2015 8:59:57 AM
Simon Evans wrote:

> Dear Mark Lawrence, thank you for your advice.
> I take it that I use the input you suggest for the line :
> 
> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid.html",lxml")
> 
> seeing as I have to give the file's full address I therefore have to
> modify your :
> 
> soup = BeautifulSoup(ecological_pyramid,"lxml")
> 
> to :
> 
> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid," "lxml")
> 
> otherwise I get :
> 
> 
>>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as
>>>> ecological_pyramid: soup = BeautifulSoup(ecological_pyramid,"lxml")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'ecological_pyramid' is not defined
> 
> 
> so anyway with the input therefore as:
> 
>>>> with open("C:\Beautiful Soup\ecologicalpyramid.html"."r")as
>>>> ecological_pyramid: soup = BeautifulSoup("C:\Beautiful
>>>> Soup\ecological_pyramid,","lxml") producer_entries = soup.find("ul")
>>>> print(producer_entries.li.div.string)

No. If you pass the filename beautiful soup will mistake it as the HTML. You
can verify that in the interactive interpreter:

>>> soup = BeautifulSoup("C:\Beautiful Soup\ecologicalpyramid.html","lxml")
>>> soup
<html><body><p>C:\Beautiful Soup\ecologicalpyramid.html</p></body></html>

You have to pass an open file to BeautifulSoup, not a filename:

>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as f:
....     soup = BeautifulSoup(f, "lxml")
.... 

However, if you look at the data returned by soup.find("ul") you'll see

>>> producer_entries = soup.find("ul")
>>> producer_entries
<ul id="producers">
<li class="producers">
</li><li class="producerlist">
<div class="name">plants</div>
<div class="number">100000</div>
</li>
<li class="producerlist">
<div class="name">algae</div>
<div class="number">100000</div>
</li>
</ul>

The first <li>...</li> node does not contain a div

>>> producer_entries.li
<li class="producers">
</li>

and thus

>>> producer_entries.li.div is None
True

and the following error is expected with the given data. 
Returning None is beautiful soup's way of indicating that the
<li> node has no <div> child at all. If you want to 
process the first li that does have a <div> child a straight-forward 
way is to iterate over the children:

>>> for li in producer_entries.find_all("li"):
....     if li.div is not None:
....         print(li.div.string)
....         break # remove if you want all, not just the first
.... 
plants

Taking a second look at the data you probably want the li nodes with
class="producerlist":

>>> for li in soup.find_all("li", attrs={"class": "producerlist"}):
....     print(li.div.string)
.... 
plants
algae


0
Peter
7/12/2015 9:51:58 AM
Dear Peter Otten, thank you for your reply that I have not gone very far into the detail of which, as it seems Python console cannot recognise the name 'f' as given it, re output below :


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("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
>>> soup = BeautifulSoup(f, "lxml")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined
>>>
0
Simon
7/12/2015 11:48:38 AM
Simon Evans wrote:

> Dear Peter Otten, thank you for your reply that I have not gone very far
> into the detail of which, as it seems Python console cannot recognise the
> name 'f' as given it, re output below :
> 
> 
> 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("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
>>>> soup = BeautifulSoup(f, "lxml")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'f' is not defined
>>>>

Is that copy-and-paste? When I try to reproduce that I get

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
.... soup = BeautifulSoup(f, "lxml")
  File "<stdin>", line 2
    soup = BeautifulSoup(f, "lxml")
       ^
IndentationError: expected an indented block

and when I indent the soup = ... line properly I don't get an error:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bs4 import BeautifulSoup
>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
....     soup = BeautifulSoup(f, "lxml")
.... 
>>> 


0
Peter
7/12/2015 12:26:28 PM
Dear Peter Otten,
Incidentally, you have discovered a fault in that there is an erroneous difference in my code of 'ecologicalpyramid.html' and that given in the text, in the first few lines re: 
----------------------------------------------------------------------------
<html> 
<body> 
<div class="ecopyramid"> 
<ul id= "producers"> 
<li class="producers"> 
<li class="producerlist"> 
<div class="name">plants</div> 
<div class="number">100000</div> 
</li> 
<li class="producerlist"> 
<div class="name">algae</div> 
<div class="number">100000</div> 
</li> 
</ul> 
----------------------------------------------------------------------------
<html>
<body>
<div class="ecopyramid">
<ul id= "producers">
<li class="producerlist">
<div class="name">plants</div>
<div class="number">100000</div>
</li>
<li class="producerlist">
<div class="name">algae</div>
<div class="number">100000</div>
</li>
</ul>
----------------------------------------------------------------------------
I have removed the line <li class="producers"> to the right html code of the lower 

version. Now there is a string ("plants") between the <"li class producerlist"> and </li>
Sorry about that.
However as you said, the input code as quoted in the text, still won't return 'plants' 

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
>>> soup = BeautifulSoup("C:\Beautiful Soup\ecological_pyramid,","lxml")
>>> producer_entries = soup.find("ul")
>>> print(producer_entries.li.div.string)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'li'
>>> 
----------------------------------------------------------------------------
0
Simon
7/12/2015 12:36:31 PM
Dear Peter Otten,=20
Yes, I have been copying and pasting, as it saves typing. I do get 'indente=
d block' error responses as a small price to pay for the time and energy th=
us saved. Also Console seems to reject for 'indented block' reasons better =
known to itself, copy and pasted lines that it accepts and  are exactly the=
 same on the following line of input. Maybe it is an inbuilt feature of Pyt=
hon's to discourage copy and pasting.
0
Simon
7/12/2015 12:48:17 PM
Simon Evans wrote:

> Dear Peter Otten,
> Yes, I have been copying and pasting, as it saves typing. I do get
> 'indented block' error responses as a small price to pay for the time and
> energy thus saved. Also Console seems to reject for 'indented block'
> reasons better known to itself, copy and pasted lines that it accepts and 
> are exactly the same on the following line of input. Maybe it is an
> inbuilt feature of Python's to discourage copy and pasting.

You should not ignore the error. It means that the respective code was not 
executed.

0
Peter
7/12/2015 1:12:15 PM
Dear Peter Otten, 
I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got: 
----------------------------------------------------------------------------
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("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
.... soup = BeautifulSoup(f,"lxml")
  File "<stdin>", line 2
    soup = BeautifulSoup(f,"lxml")
       ^
IndentationError: expected an indented block
>>> soup = BeautifulSoup(f,"lxml")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'f' is not defined
>>>
----------------------------------------------------------------------------
The first time I typed in the second line, I got the 
"Indentation error" 
the second time I typed in exactly the same code, I got the: 
"NameError:name 'f' is not defined"
0
Simon
7/12/2015 5:33:17 PM
Simon Evans wrote:

<zip>
> ---------------------------------------------------------------------
>>>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r") as

You seem to run Python under Windows.

You have to take care of escape mechanism beyond \ char in string literals 
(see Python docs). 

By chance, \B and \e are not recognized as escape sequences, so they are 
left as is. But \a \b \f \n \r \t \v \x  will be processed differently

Double \ in your string:
	"C:\\Beautiful Soup\\ecologicalpyramid.html"

Or use a raw string by prepending a r to disable escape sequences:
	r"C:\Beautiful Soup\ecologicalpyramid.html"


<zip>

A+
Laurent.

0
Laurent
7/12/2015 5:54:01 PM
On Mon, Jul 13, 2015 at 3:54 AM, Laurent Pointal
<laurent.pointal@free.fr> wrote:
> Double \ in your string:
>         "C:\\Beautiful Soup\\ecologicalpyramid.html"
>
> Or use a raw string by prepending a r to disable escape sequences:
>         r"C:\Beautiful Soup\ecologicalpyramid.html"

Or use forward slashes:
    "C:/Beautiful Soup/ecologicalpyramid.html"

ChrisA
0
Chris
7/12/2015 5:58:36 PM
On 2015-07-12 18:33, Simon Evans wrote:
>
> Dear Peter Otten,
> I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got:
> ----------------------------------------------------------------------------
> 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("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
> ... soup = BeautifulSoup(f,"lxml")
>    File "<stdin>", line 2
>      soup = BeautifulSoup(f,"lxml")
>         ^
> IndentationError: expected an indented block
>>>> soup = BeautifulSoup(f,"lxml")
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> NameError: name 'f' is not defined
>>>>
> ----------------------------------------------------------------------------
> The first time I typed in the second line, I got the
> "Indentation error"
> the second time I typed in exactly the same code, I got the:
> "NameError:name 'f' is not defined"
>
Python parses the lines, and, if there are no syntax errors, it then
executes them.

That block of code (the 2 lines) contained a syntax (indentation)
error in the second line, so _none_ of the block was executed, and,
therefore, 'f' isn't defined.

0
MRAB
7/12/2015 6:05:22 PM
On 12/07/2015 18:33, Simon Evans wrote:
>
> Dear Peter Otten,
> I typed in (and did not copy and paste) the code as you suggested just now (6.28 pm, Sunday 12th July 2015), this is the result I got:
> ----------------------------------------------------------------------------
> 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("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
> ... soup = BeautifulSoup(f,"lxml")
>    File "<stdin>", line 2
>      soup = BeautifulSoup(f,"lxml")
>         ^
> IndentationError: expected an indented block
>>>> soup = BeautifulSoup(f,"lxml")
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> NameError: name 'f' is not defined
>>>>
> ----------------------------------------------------------------------------
> The first time I typed in the second line, I got the
> "Indentation error"
> the second time I typed in exactly the same code, I got the:
> "NameError:name 'f' is not defined"
>

You can tell that to the marines :)

 >>> with open("ecologicalpyramid.html","r")as f:
....     soup = BeautifulSoup(f)
....     producer_entries = soup.find("ul")
....     producer_entries
....
<ul id="producers">
<li class="producers">
</li><li class="producerlist">
<div class="name">plants</div>
<div class="number">100000</div>
</li>
<li class="producerlist">
<div class="name">algae</div>
<div class="number">100000</div>
</li>
</ul>
 >>>

Can I suggest that you slow down.  It strikes me that you're trying to 
run a marathon a day for a year before you can even walk.  For example 
is the file path in your call to open() correct?  Frankly I very much 
doubt it, although it is possible.

Perhaps you'd be more comfortable on the tutor mailing list?  If so see 
https://mail.python.org/mailman/listinfo/tutor or gmane.comp.python.tutor.

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

Mark Lawrence

0
Mark
7/12/2015 6:23:05 PM
On Sun, 12 Jul 2015 19:33:17 +0200, Simon Evans  
<musicalhacksaw@yahoo.co.uk> wrote:

>
> Dear Peter Otten,
> I typed in (and did not copy and paste) the code as you suggested just  
> now (6.28 pm, Sunday 12th July 2015), this is the result I got:
> ----------------------------------------------------------------------------
> 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("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
> ... soup = BeautifulSoup(f,"lxml")
>   File "<stdin>", line 2
>     soup = BeautifulSoup(f,"lxml")
>        ^
> IndentationError: expected an indented block
>>>> soup = BeautifulSoup(f,"lxml")
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'f' is not defined
>>>>
> ----------------------------------------------------------------------------
> The first time I typed in the second line, I got the
> "Indentation error"
> the second time I typed in exactly the same code, I got the:
> "NameError:name 'f' is not defined"

"Expected an indented block" means that the indicated line should have  
started with at least one whitespace character more than the preceding  
line.

  >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
  ... soup = BeautifulSoup(f,"lxml")

should have been something like

  >>> with open("C:\Beautiful Soup\ecologicalpyramid.html","r")as f:
  ...     soup = BeautifulSoup(f,"lxml")
-- 
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/
0
Albert
7/12/2015 6:34:18 PM
Simon Evans -- what editor are you using to write your Python code with?

Laura Creighton


0
Laura
7/12/2015 7:47:46 PM
On 07/12/2015 05:48 AM, Simon Evans wrote:
> Dear Peter Otten,
> Yes, I have been copying and pasting, as it saves typing. I do get 'indented block' error responses as a small price
 > to pay for the time and energy thus saved.
 >
You CANNOT ignore indenting.
Indenting is NOT optional, it is REQUIRED by Python syntax.
Changing indenting TOTALLY changes the meaning.

 > Also Console seems to reject for 'indented block' reasons better known to itself, copy and
 > pasted lines that it accepts and  are exactly the same on the following line of input.
 >
As above, that is Python syntax.

 > Maybe it is an inbuilt feature of Python's to discourage copy and pasting.
 >
Absolutely not.  As noted above, this is the way Python is defined to work.

      -=- Larry -=-

0
Larry
7/12/2015 8:06:16 PM
On 12/07/2015 20:47, Laura Creighton wrote:
> Simon Evans -- what editor are you using to write your Python code with?
>
> Laura Creighton
>

Editor?  His earlier posts clearly show he's using the 2.7.6 32 bit 
interactive interpreter on Windows.

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

Mark Lawrence

0
Mark
7/12/2015 8:09:22 PM
In a message of Sun, 12 Jul 2015 21:09:22 +0100, Mark Lawrence writes:
>On 12/07/2015 20:47, Laura Creighton wrote:
>> Simon Evans -- what editor are you using to write your Python code with?
>>
>> Laura Creighton
>>
>
>Editor?  His earlier posts clearly show he's using the 2.7.6 32 bit 
>interactive interpreter on Windows.

He's sending us that stuff, but he may be writing it someplace else
first.  And that someplace else may be spitting out combined
spaces and tabs.  If he is pasting that into the interpreter,
that will cause tons of problems like he is seeing.

Laura

0
Laura
7/12/2015 8:29:21 PM
On 12/07/2015 21:29, Laura Creighton wrote:
> In a message of Sun, 12 Jul 2015 21:09:22 +0100, Mark Lawrence writes:
>> On 12/07/2015 20:47, Laura Creighton wrote:
>>> Simon Evans -- what editor are you using to write your Python code with?
>>>
>>> Laura Creighton
>>>
>>
>> Editor?  His earlier posts clearly show he's using the 2.7.6 32 bit
>> interactive interpreter on Windows.
>
> He's sending us that stuff, but he may be writing it someplace else
> first.  And that someplace else may be spitting out combined
> spaces and tabs.  If he is pasting that into the interpreter,
> that will cause tons of problems like he is seeing.
>
> Laura
>

At 18:33 BST Simon stated "I typed in (and did not copy and paste) the 
code...".  I started my reply with "You can tell that to the marines :)".

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

Mark Lawrence

0
Mark
7/12/2015 8:48:18 PM
Reply:

Similar Artilces:

Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
At the start of Chapter 3 of 'Getting Started in Beautiful Soup' it has said to create a html file, 'ecological pyramid.html' - which I have already done re: ---------------------------------------------------------------------------- <html> <body> <div class="ecopyramid"> <ul id= "producers"> <li class="producers"> <li class="producerlist"> <div class="name">plants</div> <div class="number">100000</div> </li> <li class="producerli...

'is not' or '!='
A newbie question to you; what is the difference between statements like: if x is not None: and if x != None: Without any context, which one should be preferred? IMHO, the latter is more readable. On 2014-08-18 21:35, ElChino wrote: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. > "x == y" tells you whether x and y refer to objects that are equal. "x is y&qu...

'^=' and '~='?
Hello, What is the difference between '^=' and '~='? Thanks, Duckhye ...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal''''''''''''''
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; _____________________________________________________ SELECT "criteria" FROM "criteria" WHERE "criteria" UPDATE/APPEND "field selections" RecordSource "qryExample" = above text strings" _______________________________________________________________________ When i am running a SELECT query in this manner it works fine with no problems, and accepts the values of specified linked for...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal'''''''''''''' #2
Hi, Thanks for ur help there HJ. I know how to do the tasks you specified there. I would like for the update query to use field values from some of the fields on the form (frmInvoices) such as InvoiceNumber, DateFrom, DateTo. My problem is that an append/update query can't find the values in the open Form (frmInvoices) when I specify them as; [Forms]![frmInvoices]![InvoiceNumber] a select query has no problem finding the field values on a form. please help. Aaron Hi Aaron, Could you post the entire code that you are having trouble with? Now it is not possible to see what goes wron...

if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
Hi, there. =20 I'm just curious if it ever dawned on anybody how to abbreviate this line : if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.')=20 =20 Igor Kurbeko Clinical Programmer Analyst 678 336 4328 ikurbeko@atherogenics.com =20 no brain no pain =20 how about: if not (str_mo in ('','.') or str_da in ('','.') or str_yy in ('','.')) OR if not (missing(str_mo) or missing(str_da) or missing(str_yy)) Eric On 22 Oct 03 21:13:37 GMT, ikurbeko@ATHER...

Removing the letters 't' 'i' 'x' and 'y'
Im having trouble with figuring out how to write a function which will remove the letters 't' 'i' 'x' and 'y' from any input string in matlab. for example modstr(pixy) should result in ans = 'p' or modstr(picture) should result in ans = 'pcure' if anyone could offer any help or hints i would really appreciate it. Thank You >> modstr=@(s) s(~ismember(s,'tixy')) modstr = @(s)s(~ismember(s,'tixy')) >> modstr('picture') ans = pcure % Bruno ...

Return value of 'each', 'current', 'next', 'end'
These array functions: 'each', 'current', 'next', 'end' They return a reference or a value. let's say I want to modify the last value of an array without iterating through all of them. I would do: <? end($array) ; current($array)="new value" ; ?> is that posible?? Thanks. Hermann.Richter@gmail.com wrote: > These array functions: 'each', 'current', 'next', 'end' > > They return a reference or a value. They return values. > let's say I want to modify the last value of an array without it...

A function with 'and' , 'not' , 'null' , 'car' and 'cdr'
What's this ? (defun enigma (x) (and (not (null x)) (or (null (car x)) (enigma (cdr x))))) "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983 On Wed, Oct 07 2015, CAI GENGYANG wrote: > What's this ? > > > (defun enigma (x) > (and (not (null x)) > (or (null (car x)) > (enigma (cdr x))))) Bad taste? It returns T if the list X contains nil as an element. It would be clearer to write (some #'null x). Helmut CAI GENGYANG ...

Re: if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
OR you could use ARRAY data new; set old; array igor $ (*) str_mo str_da str_yr; do over igor; if igor ~in (' ','.') then do; end; run; Prasad Ravi Igor Kurbeko <ikurbeko@ATHEROGENIC To: SAS-L@LISTSERV.UGA.EDU S.COM> cc: Sent by: "SAS(r) Subject: if str_mo not in ('','.') and str_da not in ('','.') and str_yy ...

error: expected '=', ',', ';', 'asm' or '__attrib
Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ####################...

error: expected '=', ',', ';', 'asm' or '__attrib
Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ##...

Re: '^=' and '~='?
Duckhye, According to the doc ( http://xrl.us/befwjx ) they, and one other set of characters, and the mnemonic 'NE' all represent 'NOT EQUAL'. Art ------- On Wed, 11 Feb 2009 16:52:40 -0600, Duck-Hye Yang <dyang@CHAPINHALL.ORG> wrote: >Hello, >What is the difference between '^=' and '~='? > >Thanks, >Duckhye ...

Meaning of ':' and '{}'
Hi, Please, can anyone tell me what is meaning of predicates ':' and '{}' ? ---------------- yours Advait Advait wrote: > Hi, > Please, can anyone tell me what is meaning of predicates ':' and '{}' > ? It depends on the context. : is used for module qualification of predicates. Like lists:member(X,L) The curly brackets are used in Definite Clauses Grammars: find the section on DCGs in the manual or google for it and you will find out easily. There are uses of {} as a functor in datastructures also. Cheers Bart Demoen Hello everyone,...

Web resources about - Why doesn't input code return 'plants' as in 'Getting Started with Beautiful Soup' text (on page 30) ? - comp.lang.python

Resources last updated: 1/25/2016 11:25:03 AM