Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document __path__ #47

Open
techtonik opened this issue Jul 19, 2014 · 4 comments
Open

Document __path__ #47

techtonik opened this issue Jul 19, 2014 · 4 comments

Comments

@techtonik
Copy link

This guide is a de-facto reference for all things that surrounded by double underscore, so it would be nice to see __path__ there as well.

@BobStein
Copy link

Agreed, @techtonik I'm inclined to fork and add:

  • Appendix 3: Magic Attributes (e.g. __path__ __all__)
  • Appendix 4: Magic File Names (e.g. __init__.py).

Thoughts?

@techtonik
Copy link
Author

Seems fine.

@westurner
Copy link

westurner commented Feb 21, 2019

If a package’s init.py code defines a list named __all__, it is taken to be the list of module names that should be imported when from package import * is encountered. It is up to the package author to keep this list up-to-date

https://docs.python.org/3/tutorial/modules.html#importing-from-a-package

@westurner
Copy link

westurner commented Feb 21, 2019

If the module is a package (either regular or namespace), the module object’s __path__ attribute must be set. The value must be iterable, but may be empty if __path__ has no further significance. If __path__ is not empty, it must produce strings when iterated over. More details on the semantics of __path__ are given below.

Non-package modules should not have a path attribute.

https://docs.python.org/3/reference/import.html#path

... https://docs.python.org/3/reference/import.html#import-related-module-attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants