Skip to content

Instantly share code, notes, and snippets.

@gjlondon
Created June 14, 2017 03:20
Show Gist options
  • Save gjlondon/9b3e83e9ff5b7157175a2041b00a9e63 to your computer and use it in GitHub Desktop.
Save gjlondon/9b3e83e9ff5b7157175a2041b00a9e63 to your computer and use it in GitHub Desktop.
# most of the time, don't use dots at all:
from spam import eggs
# If Python has trouble finding spam and spam.py is in the same directory:
# (i.e. "package" as the code doing the import):
from .spam import eggs
# when spam.py is in the *enclosing* package, i.e. one level up:
from ..spam import eggs
# ImportError! At least in Python 3, you can only use the dots with
# the `from a import b` syntax:
import .spam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment