I would like to know if using alias in terminal to change the default python version has positive effects on subsequent calls of python in scripts?
For example, I use
$ alias python=python36
$ ./run_program
Now assume run_program is a script that call multiple nested scripts and inside them, the command is python foo.py. Will they execute python36 or python2?
Or that alias affects only direct python commands in current shell?
alias are not exported to sub-shells. It is better to use functions for this purpose. If you want systemwide override of python2 to python36 then use this code in your $HOME/.bashrc:
python() { python36 "$@"; }
export -f python
Then check python version in any script by using:
python -V
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With