Don't understand behavior; instance form a class in another class' instance

Martin P. Hellwig martin.hellwig at dcuktec.org
Thu Mar 25 21:56:38 EDT 2010


On 03/26/10 01:10, Rhodri James wrote:
<cut>
>
> Pretty much. In the sense that you're thinking of, every assignment
> works that way, even the initial "TEST1 = One()". Assignment binds names
> to objects, though you have to be aware that names can be such exotic
> things as "t", "a[15]" or "TEST2.__instance_one.one"
>
>> I probably expected classes namespaces to behave in about the same way
>> as lists and dictionaries do, don't know where I picked that up.
>
> They do, in fact, which isn't terribly surprising considering that class
> namespaces are implemented with dictionaries. The distinction you're
> missing is that lists and dictionaries are mutable, while booleans
> aren't; you can change the contents of a dictionary, but you can't
> change the 'contents' of a boolean.
>

All makes sense now, thanks Rhodri & Christian.

-- 
mph



More information about the Python-list mailing list