file and filename in cgi module? (newbie problem with Documentation)

Bjoern google at blinker.net
Wed May 22 19:54:25 EDT 2002


Hello,

I am confused about the documentation of python. For example, in the
documentation of the cgi module it says

"If a field represents an uploaded file, accessing the value via the
value attribute or the getvalue() method reads the entire file in
memory as a string. This may not be what you want. You can test for an
uploaded file by testing either the filename attribute or the file
attribute. You can then read the data at leisure from the file
attribute:


fileitem = form["userfile"]
if fileitem.file:
     ..."


I wonder where does this .file thingy come from? I can't find anything
about it in the documentation that comes with Python, and the same
goes for filename. Is it specific to the cgi module? Are they
attributes that all return values of FieldStorage-Entries have? But
then why isn't there a descritpion of the FieldStorage class? By
chance I found that .filename will give me the name of an uploaded
file - where would have been the official place to read about it?

I just want to make sure I get the whole grasp of Python, not missing
any nifty features... I must admit that this documentation problem is
putting me off a bit already (why did I dismiss Perl to begin with?).
But I really want to like Python, so I hope it's just my mistake...;-)

Many thanks in advance for any pointers.


Bjoern



More information about the Python-list mailing list