0

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?

1 Answer 1

1

It turns out I needed to reload the module:

mod = py.importlib.import_module('example');
py.importlib.reload(mod);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.