Why less emphasis on private data?
Paul Boddie
paul at boddie.org.uk
Mon Jan 8 04:24:04 EST 2007
Paul Rubin wrote:
>
> Right, the problem is if those methods start changing the "private"
> variable. I should have been more explicit about that.
>
> class A:
> def __init__(self):
> self.__x = 3
> def foo(self):
> return self.__x
>
> class B(A): pass
>
> class A(B):
> def bar(self):
> self.__x = 5 # clobbers private variable of earlier class named A
Has this ever been reported as a bug in Python? I could imagine more
sophisticated "name mangling": something to do with the identity of the
class might be sufficient, although that would make the tolerated
"subversive" access to private attributes rather difficult.
Paul
More information about the Python-list
mailing list