Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Industrial programming >> Python

Enforce a Minimum Python Version in Your Script

Enforce a Minimum Python Version in Your Script

You can check for the Python version in your code, to make sure your users are not running your script with an incompatible version. Use this simple check:

import sys

if not sys.version_info > (2, 7):
   # berate your user for running a 10 year
   # python version
elif not sys.version_info >= (3, 5):
   # Kindly tell your user (s)he needs to upgrade
   # because you're using 3.5 features

Python

  1. Mastering Python Operators: A Comprehensive Guide
  2. Python List Operations: Creation, Access, Modification, and Advanced Techniques
  3. Mastering Python Tuples: Creation, Access, and Advanced Operations
  4. Mastering Python Dictionaries: Creation, Manipulation, and Advanced Techniques
  5. Master Python Loops: For, While, Break, Continue, and Enumerate Explained
  6. Python time.sleep(): How to Add Delays in Your Code (Example)
  7. Checking File and Directory Existence in Python – A Practical Guide
  8. Master Python Attrs: Build Advanced Data Classes with Practical Examples
  9. Efficiently Measure Python Object Memory Usage with sys.getsizeof()
  10. TV Check – CNC Dictionary Definition and Parity Explanation