class-private names and the Zen of Python

Marco Buttu marco.buttu at gmail.com
Tue Oct 8 07:15:17 EDT 2013


On 10/08/2013 01:07 PM, Ned Batchelder wrote:

> On 10/8/13 6:13 AM, Marco Buttu wrote:
>>
>> >>> class Foo:
>> ...     _Foo__a = 100
>> ...     __a = 33
>> ...
>> >>> Foo._Foo__a
>> 33
>>
...
> You also get a "problem" if you do this:
>
>      >>> class Foo:
>     ...     a = 100
>     ...     a = 33
>     ...
>      >>> Foo.a
>     33

But this does not happen under the hood, it is explicit

> Also, as Terry mentions, no one has ever assigned the two names you
> show,

Sincerely, I can not now if someone has assigned (or will assegne) in 
such way...

-- 
Marco Buttu



More information about the Python-list mailing list