Re: Way for see if dict has a key
- From: "André" <andre.roberge@xxxxxxxxx>
- Date: 30 Jun 2006 04:27:47 -0700
Michele Petrazzo wrote:
Bruno Desthuilliers wrote:
but what the better
Depends on the context.
If know only one context: see if the key are into the dict... What other
context do you know?
Michele
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
if key in dict
André
.
- Follow-Ups:
- Re: Way for see if dict has a key
- From: Fredrik Lundh
- Re: Way for see if dict has a key
- From: Michele Petrazzo
- 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
- Way for see if dict has a key
- Prev by Date: Re: Way for see if dict has a key
- Next by Date: Re: delete first line in a file
- 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):
Relevant Pages
|