title: Loading each .py file in a path - imp.load_module complains about relative import
body: <p>I am trying to parse a given path for python source files, import each file and DoStuff&trade; to each imported module.</p>
  
  <pre><code>def ParsePath(path):
      for root, dirs, files in os.walk(path):
          for source in (s for s in files if s.endswith(".py")):
              name = os.path.splitext(os.path.basename(source))[0]
              m = imp.load_module(name, *imp.find_module(name, [root]))
              DoStuff(m)
  </code></pre>
  
  <p>The above code works, but packages aren't recognized <code>ValueError: Attempted relative import in non-package</code></p>
  
  <p>My question is basically, how do I tell <code>imp.load_module</code> that a given module is part of a package?</p>