Dynamically Import a Module (and return it)

1
2
3
4
5
def dynamic_import( path ):
    l = path.rfind('.')
    parent, child = path[:l], path[l+1:]
    base = __import__(parent, globals(), globals(), [child])
    return getattr(base, child, None)

More like this

  1. Dynamic import from an installed app by Archatas 5 years ago
  2. module_from_path by simon 5 years, 11 months ago
  3. Dynamic Template Loader by jgeewax 5 years, 9 months ago
  4. Lazily lookup dynamically for templates by axiak 6 years, 1 month ago
  5. Dynamic Backends by LorenDavie 5 years, 6 months ago

Comments

wiz (on March 1, 2007):

Looks great for plugins!

#

(Forgotten your password?)