[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Obtain Python version number



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Tille wrote:
> Hi,
> 
> to write a wrapper script I wonder what might be the best possibility
> to find out the version numer of the running python interpreter. The
> wrapper script is of the type
> 
>   /var/lib/python-support/python${PYVER}/${package}/${realscript}
> 
> and I wonder, how I can obtain ${PYVER} according to the version
> of the python binary that is installed as /usr/bin/python.
> 
> I tried
> 
>   PYVER=`python -V 2>&1 | sed
> 's/Python[[:space:]]\+\([0-9]\+\.[0-9]\+\).*/\1/'`
> 
> which works in principle but I wonder if there is some other reasonable
> way.

$ PYVER=`python -c \
        'import platform; print platform.python_version()'`
$ echo $PYVER
2.3.5



- --
Ron Johnson, Jr.
Jefferson LA  USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE2DGjS9HxQb37XmcRAi9bAKDmiE+qL5vXL512c7H6Bfwva1xN6gCg2QZR
C16jk87A/hnkOmMZV2W7cZE=
=HdQX
-----END PGP SIGNATURE-----



Reply to: