Import a module by a name stored in a variable? (importlib?)

  • Pybytes Beta

    I want to import a module name stored in a variable. This StackOverflow post says it it is possible in standard Python. How would I do the same in uPython?

    Here's an example:

    $ cat
    >>> import importlib
    >>> mymodule = 'device_routines.command'
    >>> myimport = importlib.import_module(mymodule)

Log in to reply

Pycom on Twitter