Skip to content

Instantly share code, notes, and snippets.

@pfmoore
Created March 15, 2013 15:00
Show Gist options
  • Save pfmoore/5170457 to your computer and use it in GitHub Desktop.
Save pfmoore/5170457 to your computer and use it in GitHub Desktop.
Import this module at the start of a script to add version-specific subdirectories to sys.path. This lets you write generic scripts that use version-specific modules
import sys, os
here = os.path.dirname(os.path.abspath(__file__))
def add(name):
fullname = os.path.join(here, name)
if os.path.isdir(fullname):
sys.path.append(fullname)
add('py{0[0]}'.format(sys.version_info))
add('py{0[0]}{0[1]}'.format(sys.version_info))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment