A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-December/058720.html below:

[Python-Dev] PEP 8 updates/clarifications

[Python-Dev] PEP 8 updates/clarifications [Python-Dev] PEP 8 updates/clarificationsJason Orendorff jason.orendorff at gmail.com
Wed Dec 14 05:18:24 CET 2005
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
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4