Created
March 15, 2013 15:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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