[Tutor] Fast way to access items in a dictionary
Elisha Rosensweig
benshafat at gmail.com
Thu Jun 18 02:39:39 CEST 2009
Hi,
Till now, when I receive a dictionary that I'm not sure contains a certain
key, I would use the following template to access a given key:
if 'someKey' in dict.keys():
someData = dict['someKey']
is there a faster way to do this? accessing a key that does not exist will
through an exception, which is just as tiresome...
Thanks
Elisha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090617/97440032/attachment.htm>
More information about the Tutor
mailing list