cgi, classes and their instances

Klaus Neuner klaus_neuner82 at yahoo.de
Tue Jul 13 10:23:24 CEST 2004


Hello,

code (1) works, code (2) doesn't.

(1)
data = cgi.FieldStorage()
comment = data.getvalue("comment")
user_name = data.getvalue("user_name")

(2)
data = cgi.FieldStorage()
comment = cgi.FieldStorage().getvalue("comment")
user_name = cgi.FieldStorage().getvalue("user_name")

This doesn't seem to be caused by general properties of objecthood
in Python. Cf. (3).

(3)
class TestClass:
    x = "bar"
    y = "foo"
print TestClass().x
print TestClass().y

So, what is the reason for the difference between (1) and (2)?

Thanks for any hints,

Klaus



More information about the Python-list mailing list