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

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to