> On Wed, 2006-03-29 at 00:15 -0500, Michael Broe wrote:
> You can check if the dictionary key exists prior to assigning to it:
> 
>>>> if not D.has_key('c'):
> ...    D['c'] = {}
>>>> D['c']['a'] = 1

And since 2.4?

if 'c' in D: ...

Alan G.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to