[Q] ImportError by __import__() on Python >= 3.4

Makoto Kuwata kwa at kuwata-lab.com
Thu Jun 9 19:33:03 EDT 2016


On Wed, Jun 8, 2016 at 10:24 PM, Michael Selik <michael.selik at gmail.com>
wrote:

> By the way, why choose to write, import, and delete modules? I'd think
> exec'ing code would be sufficient.
>
>
In order to test my own framework for web application.
It loads controller classes lazily. In other words, it loads python module
only when it is required.

For example:

    mappings = [
        (r'/api/hello',   'myapp1.api.hello.Hello'),    #
myapp1/api/hello.py will be loaded lazily
    ]
    app = WSGIApplication(mappings)


In order to test this framework, it is necessary to create and load python
module file dynamically.

--
regars,
makoto



More information about the Python-list mailing list