[arch-general] simple trick to make dealing with python 2/3 scripts easier

Δημήτρης Ζέρβας 01ttouch at gmail.com
Fri Aug 17 18:13:12 EDT 2012


genius! :)
maybe a cronjob? (every 24 hours overwrite the script) (silly one)
maybe a startup overwrite?
or an aur package? (with interactive question if PYTHON is not set!)

-- 
(\_ /) copy the bunny to your profile
(0.o ) to help him achieve world domination.
(> <) come join the dark side.
/_|_\ (we have cookies.)



On Fri, Aug 17, 2012 at 9:09 PM, Ben Booth <benwbooth at gmail.com> wrote:

> Lots of python scripts still use #!/usr/bin/python instead of explicitly
> stating which version of python to use. Here's quick trick to make running
> various python version 2 or 3 scripts easier:
>
> remove the /usr/bin/python symlink and replace with this shell script:
>
> #!/usr/bin/env bash
> exec /usr/bin/"${PYTHON:-python3}" "$@"
>
> Now you can set the PYTHON environment variable to be either python2 or
> python3, depending on which version of python the script expects. Just
> don't
> set PYTHON=python, or you'll get a recursive loop! The only problem with
> this approach is that /usr/bin/python is owned by the python package, so if
> you upgrade the python package it might create problems. Any one know of
> some way to work around this problem?
>
>


More information about the arch-general mailing list