value exists (newbie question)

eldorado eldorado at io.com
Tue Sep 19 15:06:40 EDT 2006


Hello,

I am trying to parse some files so that if a postal code exists, but is 
longer than five digits it will return me only the first five digits:
...
for insDict in insureDict:
 	insDict['postalcode'] = insDict.get('postalcode')[:5]
...
This works, except for when I get a blank postalcode.  In which case I get 
the following error.
ERR exceptions.TypeError: iteration over non-sequence

What I would like to do is to check to make sure a value exists.  I just 
cannot seem to find the syntax to do that.  (not asking anyone to write my 
code, just looking for a pointer)

Thanks


-- 
Randomly generated signature --
In God I Trust -- on all others I use dsniff, ettercap and lczroex



More information about the Python-list mailing list