Barry Warsaw wrote: > - If your class is intended to be subclassed, and you have attributes > that you do not want subclasses to use, consider naming them with > double leading underscores and no trailing underscores. This invokes > Python's name mangling algorithm, where the name of the class is > mangled into the attribute name. This helps avoid attribute name > collisions should subclasses inadvertently contain attributes with the > same name. > > Note 1: Note that only the simple class name is used in the mangled > name, so if a subclass chooses both the same class name and attribute > name, you can still get name collisions. > > Note 2: Name mangling can make certain uses, such as debugging, less > convenient. However the name mangling algorithm is well documented > and easy to perform manually.
Hmm. How about just: "Put two leading underscores on an attribute's name to strongly discourage code outside the class from accessing it." -j _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com