Skip to content

Instantly share code, notes, and snippets.

@mirekfranc
Created May 28, 2015 15:16
Show Gist options
  • Save mirekfranc/d1c60d8d369948cc7a8f to your computer and use it in GitHub Desktop.
Save mirekfranc/d1c60d8d369948cc7a8f to your computer and use it in GitHub Desktop.
importing of ../somemodule.py
import os, inspect, sys
# without inspect
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
# or
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(inspect.getsourcefile (sys.modules[__name__]))), '..'))
import somemodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment