Skip to content

Instantly share code, notes, and snippets.

@ciembor
Created January 22, 2013 11:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciembor/4593851 to your computer and use it in GitHub Desktop.
Save ciembor/4593851 to your computer and use it in GitHub Desktop.
Switching between Python 3 and 2 in a runtime
#!/usr/bin/env python
import sys, os
print(sys.version_info[:])
if sys.version_info[0] != 2:
sys.argv.insert(0, "python2")
os.execl("/usr/bin/env", "/usr/bin/env", *sys.argv)
try:
eval('print sys.version_info[:]')
except SyntaxError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment