Name Error
Curtis Jensen
cjensen at bioeng.ucsd.edu
Wed Jan 3 17:13:51 EST 2001
Fredrik Lundh wrote:
>
> Curtis Jensen wrote:
> > Below is a bit from my Python interpreter. The "stored_data" variable
> > is a global list. It should be seen from within the "send_data"
> > function. However, I get a NameError here. I ran it with pdb; pdb is
> > able to output the "stored_data" variable from within the "send_data"
> > function. However, it still gives a NameError.
> >
> > "stored_data" works in all of my other functions except this one? Any
> > ideas?
>
> Python 1.5.2? do you by any chance assign to "stored_data" in
> that function?
>
> (if you can, please post the source for send_data...)
>
> cheers /F
Oh, I see the problem. I do assign to stored_data. It works if I
comment out the last line. I didn't think that would cause
"stored_data" to change scopes.
Would Python 2.0 not have this problem?
def send_data():
print stored_data[0]
# open connection to server if not connected
if not connected[0]:
connect()
connected[0] = TRUE
for item in stored_data:
# Convert to XML
xml_data = XML_Pickler( item ).dumps()
client.send( 'load' )
# send server the data
client.send( xml_data )
status = client.recv()
if not int( status ): # get recieved status
print 'ERROR: %s not recieved' % item.__class__.__name__
#end for item in stored_data
#clear stored_data
stored_data = []
#end def send_data
--
Curtis Jensen
cjensen at bioeng.ucsd.edu
http://www-bioeng.ucsd.edu/~cjensen/
FAX (425) 740-1451
More information about the Python-list
mailing list