On Mon, Jul 22, 2002 at 11:33:44PM -0700, Aseem Mohanty wrote:
oh crap. i had a script that put in all form data into the session for error-tracking and I was inserting a file object in a file upload form to it too.
so how do I check if the object is a file or not in thte python script?
currently I do:
for key in form.keys: try: x = key.filename except AttributeError: data.set(...)
that seems to be the dumb way to go... is there any better way to do do it.
that's actually a pretty pythonic thing to do. (but remember that keys is a method, not a list - so call it, put parentheses in there.) OTOH, if you don't need to keep the filename and you're just using it as a test, you could do this: for key in form.keys(): if hasattr(key, "filename"): # it's a file else: # it's not -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"