On Apr 17, 7:21 pm, J Kenneth King <ja...@agentultra.com> wrote: > Consider: > > code: > ------------------------------------------------------------------------ > > class MyInterface(object): > > def __get_id(self): > return self.__id > > id = property(fget=__get_id) > > def __init__(self, id, foo): > self.__id = id > self.foo = foo
I use the double underscore/name mangling mechanism only if I am sure that the __xxx attribute will be overridden in subclasses, and overriding without protection will cause issues. Otherwise I don't bother, I use a single underscore. In my mind it is obvious that a private attribute _xxx attribute should not be overridden in subclasses without care. The double underscore instead says "you can override me freely, don't worry" and I reserve it for attributes which *should* be overridden. -- http://mail.python.org/mailman/listinfo/python-list