"Private" attributes - a possible idea (maybe PEP-worthy).

Tim Peters tim.one at home.com
Sat Feb 2 14:54:00 EST 2002


[Chris Tavares]
> How about changing the name mangling rule so that the current
> number of base classes is added to the secret string?

I'm not sure what "current number of base classes" means.  In

class X(Y):
    __pvt = 1

what's the current number of base classes?  Keep in mind that name-mangling
is done at compile-time, and has only the static text of the module being
compiled to examine, so the only feasible answer I can come up with is "1".
But that wouldn't help (if Y derived from another class named X which
derived from Z, the count would be 1 on both incarnations of X).





More information about the Python-list mailing list