Paul Boddie wrote: > 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 > It would also force the mangling to take place at run-time, which would probably affect efficiently pretty adversely (thinks: should really check that mangling is a static mechanism before posting this).
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list