Question about the "new" module

skip at pobox.com skip at pobox.com
Fri Dec 29 09:11:38 EST 2006


    Gabriele> I'm using Python 2.5 to develop a simple MVC framework based
    Gabriele> on mod_python. To load my controllers, I create new modules
    Gabriele> using the "new" module like this:

    Gabriele> # ....
    Gabriele> my_module = new.module("random_name")
    Gabriele> my_module.__file__ = module_path
    Gabriele> exec open(module_path, "r") in my_module.__dict__

    Gabriele> then I initialize the class defined inside the module and call
    Gabriele> a method of this class based on the HTTP request.

Why use the new module?  Why not call __import__() or execfile()?  Details
on their use are here:

    http://docs.python.org/dev/lib/built-in-funcs.html

Skip



More information about the Python-list mailing list