On 10/10/2021 13:31, Steven D'Aprano wrote:
On Sat, Oct 09, 2021 at 08:16:58PM -0600, Finn Mason wrote:
import sys
if sys.version_info < (3, 6):
# Yell at the user
Please, version checking is usually an anti-pattern! You should use
feature detection whenever possible, not version checking.
Understood.
But would you agree that if you are writing code to be Python 2- and
Python 3-compatible, it is reasonable to check the major version:
Python3 = sys.version_info.major >= 3
....
if Python3:
# this code used to work without this bit
...
if not Python3:
# can't use this feature
etc.
Best wishes
Rob Cliffe
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/RPICFVHCLQTJECSERDV4F52OJ3SGWCTW/
Code of Conduct: http://python.org/psf/codeofconduct/