I'm trying to build a completely plug-in based system. One of my
problems is importing a package dynamically. I'm trying to emulate the
import command. The __import__() function or imp module doesn't help me
much because they only return the module. I want to register the module
with it's name in the current namespace. I can do it by:
globals()[module_name] = __import__(modu le_name)
But I don't think it's a good thing to access the global namespace
directly. I prefer using setattr() but I cannot access the current
namespace as an object I want something like
setattr(__main_ _,__import__(mo dule_name))
Is that possible? I'm using Python 2.1 on Debian Woody
--
Love, Respect, Linux
############### ############### ############### ############### ############### #
"Has anyone had problems with the computer accounts?"
"Yes, I don't have one."
"Okay, you can send mail to one of the tutors ..."
-- E. D'Azevedo, Computer Science 372
############### ############### ############### ############### ############### #
Tonguç Yumruk
problems is importing a package dynamically. I'm trying to emulate the
import command. The __import__() function or imp module doesn't help me
much because they only return the module. I want to register the module
with it's name in the current namespace. I can do it by:
globals()[module_name] = __import__(modu le_name)
But I don't think it's a good thing to access the global namespace
directly. I prefer using setattr() but I cannot access the current
namespace as an object I want something like
setattr(__main_ _,__import__(mo dule_name))
Is that possible? I'm using Python 2.1 on Debian Woody
--
Love, Respect, Linux
############### ############### ############### ############### ############### #
"Has anyone had problems with the computer accounts?"
"Yes, I don't have one."
"Okay, you can send mail to one of the tutors ..."
-- E. D'Azevedo, Computer Science 372
############### ############### ############### ############### ############### #
Tonguç Yumruk
Comment