Is there a mechanism in python3 that allows modules to run with different minor versions backward compatibility? I am imagining something like:
with compatibility('python-3.7'):
import moduleX
with compatibility('python-3.6'):
import moduleY
I don't seem to able to find anything that allows backwards compatibility except this rejected pep497. If it is not possible, why is it hard? If I have say multiple versions of python3 in different conda/virtual envs should it be possible?
Sorry if it is obvious, but I couldn't think of why/why not this is not possible in the same major version.
Edit: I am not asking to check the python version of the script or module. Let's say I already know which version is required, then how can I run in compatibility mode?
I will give an example, checking Linux versions prior to 3.7 was done using platform module, which is now removed and the suggested alternative is to use a 3rd party module such as distro. Is there a way to call a specific legacy module using a previous version of python? It can be done for a for a simple case like this but lets say your code depends on multiple different python versions. Is there a simple way to allow that?