This is an old copy of the Python FAQ. The information here may be outdated.

__import__('x.y.z') returns module 'x'; how do I get z?



For more realistic situations, you may have to do something like

m = __import__(s)
for i in s.split(".")[1:]:
    m = getattr(m, i)

CATEGORY: programming


A Django site. rendered by a django application. hosted by webfaction.