Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
What exactly is a "pseudo-module"? I can only imagine it is something like sys, which exists internally in the interpreter but doesn't have an independent existence as a .py .dll or .so file. That's not the case with `__future__`, which is an *actual* module. I think that talking about "pseudo-module" is inaccurate and confusing and I suggest we ought to drop it. The real difference is (as I understand it) is that the **syntax** from __future__ import <feature> is not an actual import, it doesn't go through the import system, it doesn't touch the `__future__` module, and it can only appear in restricted positions. (It is legal in the interactive interpreter, and as the very first executable line of code in a .py file. So after the docstring, but before any code.) So the current docs are misleading. It's not `__future__` that is special. That is a real module. It is the syntactic form that is special. It's not a pseudo-*module* but a pseudo-*import*. With a little bit of jiggery-pokery we can even get the "from ... import ..." version working: >>> from __future__ import nested_scopes as nested_scopes >>> nested_scopes _Feature((2, 1, 0, 'beta', 1), (2, 2, 0, 'alpha', 0), 16) (Only tested in the interactive interpreter, but I presume it will also work in a .py file.) So: 1. `__future__` is a real, not "pseudo", module. 2. We can import from the module like any other module. 3. It is the *syntax* `from __future__ import <feature>` that is special, not the module. 4. It behaves as a compiler directive, not an import. Let's fix the docs to describe what actually happens and drop any reference to "pseudo-module". It is needlessly confusing and inaccurate. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44693> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com