How to say $a=$b->{"A"} ||={} in Python?

Lawrence Oluyede raims at dot.com
Fri Aug 17 00:43:03 CEST 2007


beginner <zyzhu2000 at gmail.com> wrote:
> I'd like to do the following in more succint code:
> 
> if k in b:
>     a=b[k]
> else:
>     a={}
>     b[k]=a

b.setdefault(k, a)

-- 
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand 
something when his salary depends on not
understanding it" - Upton Sinclair



More information about the Python-list mailing list