[Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores
Lennart Regebro
regebro at gmail.com
Mon Jul 15 07:12:50 CEST 2013
On Mon, Jul 15, 2013 at 6:17 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> =================
> Private interfaces
>
> Unless explicitly documented otherwise, a leading underscore on any
> name indicates that it is an internal implementation detail and any
> backwards compatibility guarantees do not apply. It is strongly
> encouraged that private APIs (whether modules, classes, functions,
> attributes or other names) be clearly marked in this way, as Python
> users may rely on introspection to identify available functionality
> and may be misled into believing an API without a leading underscore
> is in fact a public API with the standard backwards compatibility
> guarantees.
Very good.
> While the explicit use of a leading underscore in the names of private
> modules is preferred, all test modules and all modules that are not
> explicitly covered in the documentation are also considered private
> interfaces, even when their names do not start with a leading
> underscore and even if they include a module level documentation
> string. This includes submodules of packages that are documented as if
> they were a single module.
But wait, aren't this about how to use other peoples modules, more
than a style guide of how to write your own modules?
I don't think this belongs in PEP 8 at all.
//Lennart
More information about the Python-Dev
mailing list