dictionary initialization

Weiguang Shi wgshi at namao.cs.ualberta.ca
Thu Nov 25 14:27:46 EST 2004


Hi,

In article <opsh1u2sow1js0xs at news.telkomsa.net>, Caleb Hattingh wrote:
> ...
>Dict entries accessed with 'string' keys, 
Not necessarily. And doesn't make a difference in my question.

> ...
>
>Which feature specifically do you want justification for?
Have it your way: string-indexed dictionaries.

   >>> a={}
   >>> a['1']+=1
   Traceback (most recent call last):
     File "<stdin>", line 1, in ?
   KeyError: '1'

a['1'] when it referenced, is detected non-existent but not
automatically initialized so that it exists before adding 1 to its
value.

Weiguang



More information about the Python-list mailing list