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 3 years, 1 month ago
  2. Template tag to create mailto links with options by celopes 2 years, 11 months ago
  3. module_from_path by simon 4 years ago
  4. Dynamic Template Loader by jgeewax 3 years, 10 months ago
  5. Django model cron jobs by willhardy 3 years, 7 months ago

Comments

wiz (on March 1, 2007):

Looks great for plugins!

#

(Forgotten your password?)