[Python] How do I dynamically import a module similar to the "import X from Y" syntax in...

Discussão em 'Python' iniciado por Stack, Abril 19, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to achieve:

    from X import Y


    where Y is a string name of a module that is only known during runtime.

    I've tried using

    module = importlib.import_module(Y, X)


    But that doesn't work. I also don't know the path of the module as it only exists during runtime within the module Brownie and is deleted afterward.

    Would very much appreciate help.

    Continue reading...

Compartilhe esta Página