Pythonic way for missing dict keys

Alex Popescu nospam.themindstorm at gmail.com
Sat Jul 21 16:42:07 CEST 2007


Bruno Desthuilliers <bdesth.quelquechose at free.quelquepart.fr> wrote in 
news:46a20fda$0$27858$426a74cc at news.free.fr:

> Alex Popescu a écrit :
>> Jakub Stolarski <jakub.stolarski at gmail.com> wrote in 
> 

>
> [snip...]
>
> 
> d = dict()
> answer = d.get('answer', 42)
> answer in d
> => False
> 

Thanks. I think to make the 3rd approach completely equivalent I should 
have been using d.setdefault(key, myojbect()).

./alex
--
.w( the_mindstorm )p.






More information about the Python-list mailing list