Ben Finney wrote: > In the specific use case of wanting a default value when a dictionary > doesn't have a particular key, you can also use this: > > >>> foo = {0: "spam", 1: "eggs", 7: "beans"} > >>> for key in [1, 2, 7]: > ... desc = foo.get(key, None)
usually spelled desc = foo.get(key) # returns None if not present or desc = foo.get(key, default) if you want something other than None. </F> -- http://mail.python.org/mailman/listinfo/python-list