Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Add note about checking sys.path for determining publicity
Browse files Browse the repository at this point in the history
  • Loading branch information
gbroques committed Aug 10, 2020
1 parent dde693f commit 2f6ab9e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/snippets/publicity.rst
Expand Up @@ -27,6 +27,12 @@ a class called ``_Foo`` is considered private. A method ``bar`` in ``_Foo`` is
also considered private since its parent is a private class, even though its
name does not begin with a single underscore.

Note, a construct's parent is recursively checked upward until we reach a directory
in ``sys.path`` to avoid considering the complete filepath of a module.
For example, consider the module ``/_foo/bar/baz.py``.
If ``PYTHONPATH`` is set to ``/``, then ``baz.py`` is *private*.
If ``PYTHONPATH`` is set to ``/_foo/``, then ``baz.py`` is *public*.

Modules are parsed to look if ``__all__`` is defined. If so, only those top
level constructs are considered public. The parser looks for ``__all__``
defined as a literal list or tuple. As the parser doesn't execute the module,
Expand Down

0 comments on commit 2f6ab9e

Please sign in to comment.