Skip to content

Instantly share code, notes, and snippets.

@samdmarshall
Created March 13, 2015 19:09
Show Gist options
  • Save samdmarshall/43bc322b66812f571f23 to your computer and use it in GitHub Desktop.
Save samdmarshall/43bc322b66812f571f23 to your computer and use it in GitHub Desktop.
# my_module/
# __init__.py
# Helpers/
# __init__.py
# plist_helper.py
# Foo/
# __init__.py
# foo.py
# Bar/
# __init__.py
# bar.py
# Bazz/
# __init__.py
# bazz.py
#
# From 'bazz.py' I want to import 'plist_helper.py', how do i do this?
@richo
Copy link

richo commented Mar 13, 2015

import my_module.Helpers.plist_helper

@richo
Copy link

richo commented Mar 13, 2015

Unless you're not planning to put this in the import path, or you want to explicitly load that file and not something potentially distributed, in which case you're probably stuck with:

os.path.insert(0, __file__ + '../../../Helpers')
import plist_helper

@samdmarshall
Copy link
Author

I've attempted to do the first suggestion and I get back "ImportError: No module named my_module.Helpers.plist_helper", I would rather not do absolute path loading but everything else i've tried cannot find the top-level module.

@pudquick
Copy link

from ....Helpers import plist_helper

(but already told you this on IRC :D)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment