russblau at hotmail.com
Thu Jun 24 20:51:37 CEST 2004
"RiGGa" <rigga at hasnomail.com> wrote in message
news:9VECc.21042$NK4.3479907 at stones.force9.net...
> I am having problems getting my script to recognize global variables and
> each time I run the script I always get this warning:
> SyntaxWarning: name 'getdata' is assigned to before global declaration
> The structure of my script is below:
> import urllib
> import sys
> global myvariable
This is in the wrong place -- you need this in the function where you are
referencing the global name (see below).
> myvariable = 0
> class MyHTMLParser(HTMLParser):
> def handle_starttag(self, tag, attrs):
> 'Do some stuff here and reassign a value to myvariable'
> def handle_data(self, data):
> if myvariable == 1:
> 'Do some more stuff here'
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.
More information about the Python-list