gl Multiple versions of python

James Mills prologic at shortcircuit.net.au
Wed Oct 29 03:00:12 CET 2008


On Wed, Oct 29, 2008 at 11:50 AM, Glenn Linderman <v+python at g.nevcal.com> wrote:
>>> When using multiple versions of Python co-installed on the same system,
>>> what happens with local .pyc files?  If the .py is loaded with a
>>> different version of Python, is the .pyc rebuilt (even if the .py hasn't
>>> changed)?

Worth having a look at virtualenv

> Also for test code, is there a way to test the version of python which is
> executing the code?  Something like
>
> if __name__ == "__main__"

<code>
#!/usr/bin/env python

import sys

def main():
   print sys.version
   print sys.subversion
   print sys.hexversion
   print sys.api_version
   print sys.version_info

if __name__ == "__main__":
   main()
</code>

<output>
2.5.2 (r252:60911, Oct 27 2008, 14:12:15)
[GCC 4.2.4 (CRUX)]
('CPython', 'tags/r252', '60911')
33882864
1013
(2, 5, 2, 'final', 0)
</output>

Read the sys documentation for the meaning
of the attributes used aboave.

cheers
James

-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list