Re: Way for see if dict has a key
- From: Michele Petrazzo <michele.petrazzo@xxxxxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 11:32:47 GMT
André wrote:
Michele Petrazzo wrote:Bruno Desthuilliers wrote:If know only one context: see if the key are into the dict... What otherbut what the betterDepends on the context.
context do you know?
Michele
Perhaps Bruno meant this:
try:
... my_dict[key] ...
except:
....
Yes I see :)
when we expect that the key will most often be in my_dict so that
exception will be raised rarely
I didn't thought this because if I think that a key aren't in a dict, I
use dict.get(key, default)
otherwise use if key in dict
André
Thanks to all,
Michele
.
- Follow-Ups:
- Re: Way for see if dict has a key
- From: Paul McGuire
- Re: Way for see if dict has a key
- References:
- Way for see if dict has a key
- From: Michele Petrazzo
- Re: Way for see if dict has a key
- From: Bruno Desthuilliers
- Re: Way for see if dict has a key
- From: Michele Petrazzo
- Re: Way for see if dict has a key
- From: André
- Way for see if dict has a key
- Prev by Date: Re: Interprocess communication on multi-user machine
- Next by Date: Re: Way for see if dict has a key
- Previous by thread: Re: Way for see if dict has a key
- Next by thread: Re: Way for see if dict has a key
- Index(es):