I usually start all my scripts with the shebang line
#!/usr/bin/env python
However our production server has Python 2 as the default python, while all of our new scripts and programs are being built under Python 3. To help keep people from accidentally running the script with the default Python 2, I am considering switching all my shebangs from now on to this;
#!/usr/bin/env python3
On our server, python3 indeed points to Python 3, and our basic scripts will run correctly on it. However I am not clear if this is something specific to our installation, or if python3 is always available if Python 3 is installed?
I know this probably will not help a user who runs $ python myscript.py when the default Python is loaded, but its better than nothing and is clear enough in letting a user who inspects the script realize they are using the wrong Python version. Though now I also realize that, with Python being on version 3.8, a Python 4 is imminent... at the same time, I am not sure I am ready to embed code in every single script to check if Python >= 3 is loaded...