How best to write this try/except block?
Chris Liechti
cliechti at gmx.net
Wed Apr 3 18:39:39 EST 2002
David Eppstein <eppstein at ics.uci.edu> wrote in news:eppstein-
055127.14142303042002 at news.service.uci.edu:
> In article <Xns91E5CE0E5919Dcliechtigmxnet at 62.2.16.82>,
> Chris Liechti <cliechti at gmx.net> wrote:
>
>> if d.has_key(key):
>> foo = stuff(d[key])
>> else:
>> foo = otherStuff(key)
>
> I've seen a couple responses suggesting this.
>
> Is there a reason why in modern Python versions one should still use
> has_key? I like the syntax "if key in d" better.
i like it also but its still very new (py 2.2)...
[Python22/Doc/lib/typesmapping.html]
chris
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list