[Tutor] confused: classes containing dicts
Calum Mackay
calum.mackay at cdmnet.org
Sat Oct 9 04:18:36 CEST 2004
Bob Gailer wrote:
> No - there is a difference in the target of the assignment:
> >>> x.l = 456 is an assignment to attribute l of instance x. SInce the
> instance attribute did not exist, it is created.
> >>> x.l["a"] = 123 is an assignment to a key in the dictionary x.l, not
> to the attribute x.
right, thanks. And since l doesn't exist in x it finds it in the class
C.l and makes the assignment there.
thanks very much for clearing up my confusion, chaps.
have a good weekend.
cheers,
calum.
More information about the Tutor
mailing list