How does __future__ module work in Python 2.7?

In Python 2.7, using a module __future__and print_functionyou can use the python 3.X print function. My question is: how did the Python developers know what was going to happen in future releases of Python? Or was this module added in Python 2.7 after its release? Here is the code I'm talking about:

from __future__ import print_function
print("Hello world!")
+4
source share
1 answer

The module __future__was introduced in Python 2.1 for access to upcoming functions / functions, which will lead to incompatibility with the current one and, if necessary, is extended with each version.

, . , .

, :

__future__ :

  • , , .
  • , 2.1, , ( __future__ , 2.1).
  • , , . __future__ .
+3

Source: https://habr.com/ru/post/1629232/


All Articles