Skip to content

Instantly share code, notes, and snippets.

@rclmenezes
Created September 15, 2016 23:46
Show Gist options
  • Save rclmenezes/045a535e8352555463c5943ebbf10907 to your computer and use it in GitHub Desktop.
Save rclmenezes/045a535e8352555463c5943ebbf10907 to your computer and use it in GitHub Desktop.
Python namespacing

Say you want a Moat Pro "common" package that looks like this:

moatpro moatpro - init.py - models - lib - db ...etc...

  • setup.py

This means that models can be imported through from moatpro.models import *.

Now let's say you want to add an optional web package within the moatpro namespace. Once you install this package, moatpro.web.views becomes an available import:

moatpro_web web - init.py - views

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