title: What are prevalent techniques for enabling user code extensions in Python?
body: <p>I'm looking for techniques that allow users to override modules in an application or extend an application with new modules.</p>
  
  <p>Imagine an application called pydraw. It currently provides a Circle class, which inherits Shape. The package tree might look like:</p>
  
  <pre><code>/usr/lib/python/
  └── pydraw
      ├── __init__.py
      ├── shape.py
      └── shapes
          ├── circle.py
          └── __init__.py
  </code></pre>
  
  <p>Now suppose I'd like to enable dynamic discovery and loading of user modules that implement a new shape, or perhaps even the Shape class itself.  It seems most straightforward for a user's tree to have the same structure as the application tree, such as:</p>
  
  <pre><code>/home/someuser/python/
  └── pydraw
      ├── __init__.py
      ├── shape.py       &lt;-- new superclass
      └── shapes
          ├── __init__.py
          └── square.py   &lt;-- new user class
  </code></pre>
  
  <p>In other words, I'd like to overlay and mask an application tree with same-named files from the user's tree, or at least get that apparent structure from a Python point of view.</p>
  
  <p>Then, by configuring sys.path or PYTHONPATH, pydraw.shapes.square might be discoverable.  However, Python's module path search doesn't find modules such as square.py.  I presume this is because <code>__method__</code> already contains a parent module at another path. </p>
  
  <p>How would you accomplish this task with Python?</p>