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
Unclear definition of the "__future__" module in Docs #88859
Comments
In Doc/glossary.rst, the first sentence of the entry "__future__" is that "A pseudo-module which programmers can use to enable new language features which are not compatible with the current interpreter." However, in Doc/library/future.rst, the first sentence is that ":mod:`__future__` is a real module, and serves three purposes:" Is there any contradiction of these two descriptions, that "pseuso-module" and "real module" refer to the same module? And if so, should we fix one of them? Thanks for review! |
I agree that the contradiction should be resolved. There is an actual But when we use the special syntax:
it doesn't do a normal import of the |
It sounds like that both descriptions (pseudo- and real) are true in different points of view on the __future__ module. I have no idea how to resolve this contradiction of the original design of the module. Any suggestion? Thanks for reply. |
It’s both! The compiler has special handling for this line (pseudo-module), and the interpreter does a regular import that gets the regular python module which can be used for introspection (the third purpose noted in the module doc). |
I thnk the glossary should say both. Approximately: "When the first statement of a program starts 'from __future__ import feature', a pseudo-module ... . When used later in a program, <link> __future__ is a real module." Link each statement to an appropriate place in the doc. |
What exactly is a "pseudo-module"? I can only imagine it is something That's not the case with The real difference is (as I understand it) is that the **syntax**
is not an actual import, it doesn't go through the import system, it (It is legal in the interactive interpreter, and as the very first So the current docs are misleading. It's not With a little bit of jiggery-pokery we can even get the "from ... import >>> 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 So:
Let's fix the docs to describe what actually happens and drop any |
I agree with Steven's more careful analysis and with canning 'pseudo'. Current suggestion. A *future statement*, "from __future__ import *feature* ...", directs the compiler to compile the current module using syntax or semantics that will become standard in a future release of Python. The *future module* documents the possible values of *feature*. Cross reference *future statement to <reference/simple_stmts.html#future-statements> and *future module* to its doc chapter. The first sentence above is based on the first sentence of the future statement doc. |
Applying above suggestions, the first sentence of the entry "__future__" would be replaced by: A :ref:`future statement <future>`, "from __future__ import *feature* ...", directs the compiler to compile the current module using syntax or semantics that will become standard in a future release of Python. The :mod:`__future__` module documents the possible values of *feature*. And the confusing sentence, "A pseudo-module which programmers can use to enable new language features which are not compatible with the current interpreter." would be removed. Can I fix this issue this way? -- |
Yes, ask me to review. |
New changeset 0363a40 by Steven Hsu in branch 'main': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: