Dec-16-2019, 05:30 AM
I want to have code that uses Python 3.7's
,
but I also want the code to run on older versions of Python (e.g. 3.5).
I have tried:
but that fails with:
Is there any way to guard the import so that it will be ignored on older python versions, but work with python versions that support the import ?
Thanks,
Brendan.
1 |
from __future__ import annoations |
but I also want the code to run on older versions of Python (e.g. 3.5).
I have tried:
1 2 3 4 |
try : from __future__ import annotations except ImportError: pass |
1 2 3 4 |
File "test_import_annotations.py" , line 6 from __future__ import annotations ^ SyntaxError: future feature annotations is not defined |
Thanks,
Brendan.