Skip to content

Instantly share code, notes, and snippets.

@raymondberg
Created October 2, 2018 16:26
Show Gist options
  • Select an option

  • Save raymondberg/7058f3e1b76b98434906609892eb0136 to your computer and use it in GitHub Desktop.

Select an option

Save raymondberg/7058f3e1b76b98434906609892eb0136 to your computer and use it in GitHub Desktop.
Explaining module imports in python
- bin
- theirmod
- __init__.py/
- mymod/
- __init__.py
- more/
- __init__.py
- other.py
- magic.py
- new_mod/
- __init__.py -> 'from .two import Blah'
- two.py
import mymod #yes
import theirmod #yes
import magic #no
import bin #no
import mymod.magic #yes
import mymod.more #no
import mymod.more.other #no
import new_mod
from new_mod import Blah
from new_mod.two import Blah
import new_mod.two
import [module]
from [module] import [object]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment