All I want to know is what exactly does __package__ mean? Didn\'t find any explanation in the official doc, even on SO.
If you could pr
See the PEP 366 and import system reference documentation:
The major proposed change is the introduction of a new module level attribute,
__package__. When it is present, relative imports will be based on this attribute rather than the module__name__attribute.
and
- The module’s
__package__attribute should be set. Its value must be a string, but it can be the same value as its__name__. If the attribute is set toNoneor is missing, the import system will fill it in with a more appropriate value. When the module is a package, its__package__value should be set to its__name__. When the module is not a package,__package__should be set to the empty string for top-level modules, or for submodules, to the parent package’s name. See PEP 366 for further details.
So, for a module located in foo/bar/baz.py, __name__ is set to foo.bar.baz, and __package__ is set to foo.bar, while foo/bar/__init__.py will have foo.bar for both the __name__ and __package__ attributes.