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

Chris Tavares christophertavares at earthlink.net
Sat Feb 2 02:52:21 EST 2002


"Delaney, Timothy" <tdelaney at avaya.com> wrote in message
news:mailman.1012520714.2778.python-list at python.org...
[... snip ...]
>
> I'd like to close this thread here (which I created because I thought I'd
> come up with a way to get around the wart) unless someone *can* come up
with
> a way to deal with it.
>
> Tim Delaney
>

How about changing the name mangling rule so that the current number of base
classes is added to the secret string? That way, the first TimKlass's
variables would be __TimKlass_0_Something, and the derived one would be
__TimKlass_1_Something.

This should work in the presence of multiple inheritance, and is fairly
simple. It could possibly break if people are screwing around with their
base classes at run time, at which point I'd say "Don't do that!"

-Chris






More information about the Python-list mailing list