problem with lists

Donn Cave donn at u.washington.edu
Tue Jul 6 13:02:22 EDT 1999


Peter Posselt Vestergaard <posselt at daimi.au.dk> writes:
| It seems like I've completely misunderstood something or at least done
| something wrong. There's noway I can see why these two scripts are
| outputting nothing or more correctly only the 4 first lines which cannot
| be seen in a browser. Anybody knows why?

I don't see any reference to nydata before its insert() operation,
so I would expect a NameError exception.

nydata.insert(0, 'hej') looks in the module namespace for an "nydata",
and then looks in that object's namespace for an "insert" attribute.
I guess you may want to bind that name to an initially empty list,
nydata = [].

	Donn Cave, University Computing Services, University of Washington
	donn at u.washington.edu
-----------------------------
| #!/usr/local/bin/python
| import cgi
|
| print "Content-type: text/html"
| print
|
| print "<HTML><HEAD>"
| print "<TITLE> Ændring af data </TITLE>"
| print '</HEAD><BODY BGCOLOR="#FFFFFF"><FONT FACE="Helvetica">'
|
| nydata.insert(0,'hej')
| print nydata[0]
| print 'strange'
|
| print '</BODY></HTML>'




More information about the Python-list mailing list