imp.load_source() - explanation needed

Albert Hopkins marduk at letterboxes.org
Wed Apr 1 22:34:30 CEST 2009


On Wed, 2009-04-01 at 12:17 -0700, mynthon wrote:
> Hi!
> 
> I need help. I don't understand what doc says.
> 
> I load module from path testmod/mytest.py using imp.load_source(). My
> code is
> 
> import imp
> testmod = imp.load_source('koko', 'testmod/mytest.py)
> print testmod
> 
> but i don't understand whatt is first (name) argument for. Docs says
> that "The name argument is used to create or access a module object."
> But i still don't understand. I cant do this
> 
> import imp
> testmod = imp.load_source('koko', 'testmod/mytest.py)
> print koko
> 

I think that importing and loading are seperate steps. So either

>>> koko = imp.load_source('koko', 'testmod/mytest.py')

or 

>>> imp.load_source('koko', 'testmod/mytest.py')
>>> import koko







More information about the Python-list mailing list