[Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores
Antoine Pitrou
solipsis at pitrou.net
Mon Jul 15 21:56:45 CEST 2013
On Mon, 15 Jul 2013 15:51:31 -0400
Barry Warsaw <barry at python.org> wrote:
> 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++.
C++ doesn't have a monopoly over the definition of "private".
> 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".
If it doesn't have any notion of privateness, then it can't have a
notion of "publicness" either.
If you really want another word (I am personally fine with "private"),
"internal" it should be.
Regards
Antoine.
More information about the Python-Dev
mailing list