[Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

Barry Warsaw barry at python.org
Mon Jul 15 21:51:31 CEST 2013


On Jul 14, 2013, at 06:11 PM, Nick Coghlan wrote:

>Private interfaces

PEP 8 does say:

    _single_leading_underscore: weak "internal use" indicator. E.g. from M
    import * does not import objects whose name starts with an underscore.

I'm in favor of making this a stronger recommendation, but I have a small
semantic quibble.  Instead of "private interface" it should be "non-public
interface".  The two aren't quite the same thing; for example, often
single-leading underscores are used for methods that subclasses are supposed
to override, e.g. akin to "protected" in C++.

Besides, Python doesn't really have any strong notion of privateness, so
saying "non-public" means "just because you can, doesn't mean you should".

-Barry


More information about the Python-Dev mailing list