Last active
November 22, 2019 03:04
-
-
Save planetceres/022d2efc657bab915ab55f2081b2c1ac to your computer and use it in GitHub Desktop.
load python module dynamically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://stackoverflow.com/questions/301134/how-to-import-a-module-given-its-name-as-string | |
import importlib | |
py_module = "std_msgs.msg" | |
py_class = "String" | |
PyClass = getattr(importlib.import_module(py_module), py_class)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment