Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
howto get function from module, known by string names?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="dmitrey, post: 2889637"] hi all, can anyone explain howto get function from module, known by string names? I.e. something like def myfunc(module_string1, func_string2, *args): eval('from ' + module_string1 + 'import ' + func_string2') return func_string2(*args) or, if it's impossible, suppose I have some modules module1 module2 module3 ... etc each module has it own funcs 'alfa', 'beta' and class module1, module2,... with same string name as module name. can I somehow pass module as function param and then import function 'alfa' from (for example) module8? and/or import class moduleN from moduleN? something like def myfunc(moduleK, *args): return moduleK.moduleK(*args) or return moduleK.alfa(*args) Thx, D [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
howto get function from module, known by string names?
Top