I have to admit that Python bewitched me: I’m in that phase when you simply can’t stop coding, testing, playing with rules and essentially having lot of fun.
On my Fedora 18 box I decided to go with Python3 as default Python version. F18 ships with Python2.7 - both version can coexist, since all executables related to version 3 are named after the ‘python3-…’ pattern. If we want to stand by python 3 (ie. launch our scripts under python3 directly from our IDE - Geany to name one), we just need to point the symbolic link /bin/python from python2 to python3. At the moment, the only downside I stumbled upon is yum refusing to work as expected (throws errors). The quickest solution I thought of is to switch back to python2 when invoking yum, then falling back to python3 after yum job is completed… So here comes my self-explaining bash script. Enjoy!
#!/bin/bash # yum3.sh # v201303191415 # https://blog.agate.pw # [Tested on Fedora 18 x86_64 - yum-3.4.3-51 + python-2.7.3-13 + python3-3.3.0-1] # yum refuses to deal with python3 as default python version # here’s a simple and dirt python version switcher # just copy to /bin/ and launch from your path as you would as usual # [sudo] yum3 [options] [command] [package(s)] if [ -L /bin/python3 ] ; then echo -e “\e[00;31m * Switching to Python2 for YUM’s sake \e[00m” # removing symlink && creating symlink to python2 rm -f /bin/python && ln -s /bin/python2 /bin/python /bin/yum $@ echo -e “\e[00;31m * Falling back to Python3 \e[00m” # removing symlink && creating back symlink to python3 rm -f /bin/python && ln -s /bin/python3 /bin/python else echo -e “\e[00;31m * No symlink found, refusing to proceed \e[00m” fi exit 0