This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients steven.daprano, vanrein
Date 2020-02-15.12:08:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581768507.64.0.80911870738.issue39637@roundup.psfhosted.org>
In-reply-to
Content
> Shouldn't that say that "'environ' is not a package" instead?

No. The os module is special, so I'll talk about the usual case first.

Normally, for `import spam.eggs` to succeed, *spam* has to be a package, and *eggs* has to be either a sub-module inside that package, or a sub-package. So the general error message is correct. You can't normally use the dotted import syntax to import functions from a module.

But the `os` module is special: it is very old, pre-dating the invention of packages, and the `os` module fakes a pretend package for `os.path` by doing this:

    sys.modules['os.path'] = path


So even though `os` is not a package, you can still use dotted package syntax to import `os.path`.

I guess this was intended as a convenience, without considering how this could be confusing.
History
Date User Action Args
2020-02-15 12:08:27steven.dapranosetrecipients: + steven.daprano, vanrein
2020-02-15 12:08:27steven.dapranosetmessageid: <1581768507.64.0.80911870738.issue39637@roundup.psfhosted.org>
2020-02-15 12:08:27steven.dapranolinkissue39637 messages
2020-02-15 12:08:27steven.dapranocreate