dictionary wart
Jesper Olsen
jolsen at mail2world.com
Thu Mar 18 07:41:38 EST 2004
Does python have a way of defining a dictionary default?
I think not, but are there any plans to incorporate it?
Intuitively I would imagine that
a={}
a.set_default(my_default)
would do this -ie. a[my_new_key] should now return the the default
value my_default instead of creating an exception. This would be
similar to how it is done in other languages, eg. Ruby:
a={}
a.default=value
But surprisingly, in python set_default is a dictionary method used
for looking up a key...
Jesper
More information about the Python-list
mailing list