how to test attribute existence of feedparser objects

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Dec 10 12:51:16 EST 2011


On Sat, 10 Dec 2011 09:19:31 -0800, xDog Walker wrote:

> Use standard Python dictionary functions such as has_key to test whether
> an element exists.

Idiomatic Python code today no longer uses has_key.

# Was:
d.feed.has_key('title')

# Now preferred
'title' in d.feed



-- 
Steven



More information about the Python-list mailing list