I have gone through questions about how does the future module works.
What is __future__ in Python used for and how/when to use it, and how it works
and
How __future__ imports work under the hood .
But what I still don't understand is that how does a interpreter created today, knows the syntax of the code that is part of future releases.
What I'm thinking is that when they create a python interpreter for 2.7 version, they build the code and create an executable and don't touch it or modify it and the users will download it and use it. Let's say that python 2.7 executable is created in the year 2009.
And python 3.7 executable is created in 2017, how does python 2.7 knows what code to compile when it imports print_function? How does python 2.7 interpreter know what is the code for print_function is going to be which will be introduced after the interpreter is created.
Am I looking at it in the right way or completely wrong?
Can someone please demystify this.
__future__module contains methods that are 'backported' to python2, the interpreter doesn't need to know about any future developments. - rdasprintis not a special keyword. This allows it to be defined as a function in the module. - Barmar