[Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon Jul 15 05:55:37 CEST 2013


On 15 Jul 2013 13:46, "Steven D'Aprano" <steve at pearwood.info> wrote:

On Mon, Jul 15, 2013 at 10:01:17AM +1000, Cameron Simpson wrote: > On 15Jul2013 09:48, Steven D'Aprano <steve at pearwood.info> wrote: > | I'd go further, and say that no more private modules should be > | accepted for the std lib unless they have a leading underscore. I > | suppose for backwards compatibility reasons, we probably can't go > | through the std lib and rename private modules to make it clear they > | are private, but we don't have to accept new ones without the > | underscore. > > I disagree. > > A private module is a perfectly sane way to implement the internals > of something, especially if it is subject to implementation change > in the future. Of course private modules are sane. I never suggested "no new private modules at all". But putting them in the same namespace as public modules is not, just to save a leading underscore in the file name.

It's not to save a leading underscore - it's to avoid renaming existing packages like pip and idlelib.

Cheers, Nick.

You don't even have to use the underscore in your own code: import stuff as stuff is allowed, and doesn't make stuff.py public since imported modules are considered implementation details by default.

-- Steven


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130715/3d115c1f/attachment.html>



More information about the Python-Dev mailing list