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 StevenHsuYL, docs@python, eric.araujo, steven.daprano, terry.reedy
Date 2021-07-24.03:04:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20210724030143.GB3540@ando.pearwood.info>
In-reply-to <1627074850.06.0.736470553633.issue44693@roundup.psfhosted.org>
Content
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.
History
Date User Action Args
2021-07-24 03:04:59steven.dapranosetrecipients: + steven.daprano, terry.reedy, eric.araujo, docs@python, StevenHsuYL
2021-07-24 03:04:59steven.dapranolinkissue44693 messages
2021-07-24 03:04:59steven.dapranocreate