I'm trying to import functions from a python script. I actually had an old python script, example.py, which looked roughly like this:
# -*- coding: utf-8 -*-
def A():
return 1
When I import this module, py.importlib.import_module('example'), it finds function A().
I now add a new function:
# -*- coding: utf-8 -*-
def A():
return 1
def B():
return 2
When I now import example, it still only finds A, and not B.
Is there something I need to do to get MATLAB to detect the new function?
It turns out I needed to reload the module:
mod = py.importlib.import_module('example');
py.importlib.reload(mod);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.