(Apr-29-2019, 06:56 AM)Gribouillis Wrote: If this is python 2 code that you want to convert to python 3, use the 2to3
utility. It will remove the unnecessary __future__
imports and probably keep the rest of the code working. Note that __future__
imports still exist in python 3.
i had been writing my code to work in
both Python2 and Python3. now that Python2 is less than a year from
EOL, i have decided to drop it entirely and only write for Python3. i don't need to use the
2to3
utility because all my code already works in Python3 (and most probably still also works in Python2, but i really don't care about that, anymore.
what do the
__future__
imports do in Python3? i thought they did nothing, though i could believe that if a Python4 ever comes out that
__future__
could have a new use.
if the
2to3
utility removes the
__future__
imports then i suppose it is safe for me to do so. just doing only that should have no effect on running that code under Python3, right? if it runs OK
with the
__future__
imports under Python3, then it should also run
without, right?
(Apr-29-2019, 09:58 AM)DeaD_EyE Wrote: You can add:
from __future__ import annotations
PEP 563
The __future__ module is still used to introduce changes.
https://docs.python.org/3/library/__future__.html
none of my code imports annotations (yet). i can add that import if/when i use annotations, right?
Output:
lt2a/phil /home/phil 20> rls +f|pygrep|whathas annotations
lt2a/phil /home/phil 21> rls +f|pygrep|whathas __future__|lc
10306
lt2a/phil /home/phil 22>