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.
For example, if you need the lcm function (least common multiple),
rather than checking for Python 3.9, you should try to import it:
try:
from math import lcm
except ImportError:
...
which then gives you the opportunity to fallback on another version,
imported from a third-party library, or to roll your own pure-Python
implementation which may not be as full-featured or fast, but will get
the job done.
Feature detection also allows you to back-port necessary functionality
via the PYTHONSTARTUP or usercustomize module, by monkey-patching the
needed class or function into the appropriate module.
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/VNBQKEIGATVMJSMB4QYLTYLNYDHANEX4/
Code of Conduct: http://python.org/psf/codeofconduct/