How to say $a=$b->{"A"} ||={} in Python?
- From: beginner <zyzhu2000@xxxxxxxxx>
- Date: Thu, 16 Aug 2007 22:35:50 -0000
Hi All.
I'd like to do the following in more succint code:
if k in b:
a=b[k]
else:
a={}
b[k]=a
a['A']=1
In perl it is just one line: $a=$b->{"A"} ||={}.
Thanks,
Geoffrey
.
- Follow-Ups:
- Re: How to say $a=$b->{"A"} ||={} in Python?
- From: Sébastien Buchoux
- Re: How to say $a=$b->{"A"} ||={} in Python?
- From: beginner
- Re: How to say $a=$b->{"A"} ||={} in Python?
- From: Jonathan Gardner
- Re: How to say $a=$b->{"A"} ||={} in Python?
- From: James Stroud
- Re: How to say $a=$b->{"A"} ||={} in Python?
- From: Carl Banks
- Re: How to say $a=$b->{"A"} ||={} in Python?
- From: Lawrence Oluyede
- Re: How to say $a=$b->{"A"} ||={} in Python?
- Prev by Date: Canceling events from COM Objects
- Next by Date: Re: How to say $a=$b->{"A"} ||={} in Python?
- Previous by thread: Canceling events from COM objects
- Next by thread: Re: How to say $a=$b->{"A"} ||={} in Python?
- Index(es):