[Python-Dev] import problems (original) (raw)
Mart Somermaa mrts at mrts.pri.ee
Fri Nov 28 11:02:21 CET 2008
- Previous message: [Python-Dev] __import__ problems
- Next message: [Python-Dev] __import__ problems
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The variant proposed by Hrvoje Niksic:
>>> import(modname) >>> mod = sys.modules[modname] looks more appealing, but comes with the drawback that sys has to be imported for that purpose only. That is not a real drawback, as "sys" will certainly be present in the system, so the "importing" boils down to a dict lookup and a variable assignment.
I meant that you have to
import sys
only to access sys.modules (i.e. importing sys may not be necessary otherwise).
Compare
mod = import(modname, submodule=True)
with
import sys import(modname) mod = sys.modules[modname]
- Previous message: [Python-Dev] __import__ problems
- Next message: [Python-Dev] __import__ problems
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]