Dictionary assignment

Istvan Albert ialbert at mailblocks.com
Sat Aug 16 16:19:39 CEST 2003

John J. Lee wrote:

> Maybe it's surprising to some Perl users.  Personally, it doesn't
> surprise me (and I did come from Perl) that if you didn't add a key 2
> to the dictionary a, it complains when you look up 2 in that dict.

What I meant to say is that it looks confusing because the

a[2][3] = 4

looks like and straightforward assignment but resolves to a lookup
followed by an assignment. That is the reason the original
poster had the problem in question.


More information about the Python-list mailing list