"André" wrote:

> Perhaps Bruno meant this:
>
> try:
>    ... my_dict[key] ...
> except:
> ...
>
> when we expect that the key will most often be in my_dict so that
>exception will be raised rarely, otherwise use

on my machine, "key in dict" is about twice as fast as the full try/getitem con-
struct when the key is present in the dict, so that's not a very good 
optimization.

now, if the OP had been interested in the associated value, things might have
been a bit different.

</F> 



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to