On 29/03/06, Michael Broe <[EMAIL PROTECTED]> wrote:
> Well I ran into an interesting glitch already. For a dictionary D, I
> can pull out a nested value using this syntax:
>
>  >>> D['b']['a']
> 23
>
> and I can assign to this dictionary using
>
>  >>> D['d'] = {'a':7, 'b':0'}
>
> but I can't assign like this:
>
>  >>> D['d']['c'] = 1
> TypeError: object does not support item assignment.

I can't reproduce this...

>>> D = {}
>>> D['d'] = {'a':7, 'b':0}
>>> D['d']['c'] = 1
>>> D
{'d': {'a': 7, 'c': 1, 'b': 0}}

Are you sure you haven't mistakenly assigned something other than a
dict to D or D['d'] ?

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

Reply via email to