[Python] Python, search from where import is call

Discussão em 'Python' iniciado por Stack, Março 26, 2025.

  1. Stack

    Stack Membro Participativo

    For managing transition from an old import to a new import, I search to log from where my module is used.

    By example, my old is name m_old.py. With a simple print in file m_old.py, I display a message "used of old module". So each time there is "import m_old.py", I have a message "used of old module" in execution ?

    If it was a function, I will use module inspect and traceback to log in execution from where this function is call, by exemple "call of old function from file.py line XXX".

    Is-it possible to display a message like : "this old import is call from file.py line XXX" ?

    (I have found nothing in inspect or traceback module to do this)

    Continue reading...

Compartilhe esta Página