On Aug 16, 6:35 pm, beginner <[EMAIL PROTECTED]> wrote:
> 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

Define b as a default dict:

b = defaultdict(dict)
b[k]['A'] = l



Carl Banks

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to