[Python] Is there a way to rename a function during import?

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a class like this:

    # in bar.py
    class Bar:
    ...
    @staticmethod
    def foo():
    ...


    Is there a way to import Bar.foo in another python file, but rename it, so it can be called by invoking foo()? I have tried import bar, from bar import Bar but none of those work.

    Continue reading...

Compartilhe esta Página