title: Hacking python's import statement
body: <p>I'm building a Python module for a fairly specific purpose. What I'd like to do with this is get more functionality behind <code>import</code>ing things from it. </p>
  
  <p>I'd like to have a setup by which saying <code>from my_module import foo</code> would run a function and pass the string <code>"foo"</code>. This function would return the object that should be imported. </p>
  
  <p>For example, maybe I want to make a cloud-based import system. I'd like to store community scripts in the cloud, and then download them when a user tries to import them. </p>
  
  <p>Maybe I use the code <code>from cloud import test_module</code>. This would check a cache to decide whether <code>test_module</code> had been downloaded. If so, it would return that module. If not, it would download the module before importing it. </p>
  
  <p>How can I accomplish something like this in Python, by which a dynamic range of submodules could be seamlessly <code>import</code>ed from the cloud? </p>