'Is importing form __future__ reliable? [duplicate]
My understanding is that importing from __future__ lets me use functions that are not yet part of the released python. This sounds like they are still works in progress, like the beta (seed) releases of apps or OS's. If they were totally finished, and thoroughly tested for all anticipate interactions and edge cases, then they would already be in an official release of python, right? Am I right that if I use a function I imported from __future__, then I'm risking something not working the way I had hoped/expected? Not working as advertised?
Solution 1:[1]
The __future__ module doesn't really let you use new functions, but rather lets you enable new or changed features which have the potential to break existing code. It's intended to let developers ensure their code will adapt to future versions of Python, with the option of keeping them disabled in production until the code is entirely updated to work with the feature.
Most of the features listed in the __future__ are actually enabled by default as the version they were enabled in was reached. Currently, the only feature not enabled by default now is annotations, which causes all type hints to be interpreted as strings, which prevents circular references and allows circular imports due to static typing to be prevented.
So the new features in __future__ are perfectly safe to use, and you don't risk breaking your code if you choose to use them.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Miguel Guthridge |
