I\'d like to include Python scripting in one of my applications, that is written in Python itself.
My application must be able to call extern
Use __import__
to import the files provided by the user. This function will return a module. Use that to call the functions from the imported file.
Use try..except
both on __import__
and on the actual call to catch errors.
Example:
m = None
try:
m = __import__("external_module")
except:
# invalid module - show error
if m:
try:
m.user_defined_func()
except:
# some error - display it