By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,002 Members | 1,171 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,002 IT Pros & Developers. It's quick & easy.

How can I load a module when I will only know the name 'on the fly'

P: n/a


m = get_next_module()

some_nice_function_somehow_loads( m )

Thanks,

Tobiah
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Tobiah wrote:


m = get_next_module()

some_nice_function_somehow_loads( m )


that'd be

mymodule = __import__('modulename')
Jeff Shannon

Jul 18 '05 #2

P: n/a
use built-in function: __import__

m = __import__('sys', globals())
print m.platform

weir

"Tobiah" <to**@rcsreg.com> >

m = get_next_module()

some_nice_function_somehow_loads( m )

Thanks,

Tobiah

Jul 18 '05 #3

P: n/a
imp.find_module() and imp.load_module:

http://www.python.org/doc/2.3.4/what...on-pep302.html
http://docs.python.org/lib/module-imp.html

renwei wrote:
use built-in function: __import__

m = __import__('sys', globals())
print m.platform

weir

"Tobiah" <to**@rcsreg.com> >

m = get_next_module()

some_nice_function_somehow_loads( m )

Thanks,

Tobiah


Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.