Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > imp.load_source() - explanation needed

Reply
Thread Tools

imp.load_source() - explanation needed

 
 
mynthon
Guest
Posts: n/a
 
      04-01-2009
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

How i can access module object using its name? Is " print sys.modules
['koko'] " only way or am i missing something?
 
Reply With Quote
 
 
 
 
Albert Hopkins
Guest
Posts: n/a
 
      04-01-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





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Explanation needed of binary operators NoNeYa Java 42 08-22-2007 09:03 PM
CONCEPT OF DAO IN J2EE --- EXPLANATION NEEDED soody Java 2 06-05-2007 08:35 AM
standalone in prolog: specs explanation needed VK XML 1 05-18-2006 10:43 PM
explanation needed on const pointers deepunayak@gmail.com C Programming 9 02-16-2006 10:31 PM
explanation needed for optical illusion in digital photo Eigenvector Digital Photography 27 08-02-2003 05:20 AM



Advertisments