I
I
Ilya Chichak2017-06-19 06:16:54
Django
Ilya Chichak, 2017-06-19 06:16:54

Is it possible to find out which application called the method?

There is a method that should work differently depending on which application called it.
Can this be done somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-06-19
@ilya_chch

You can use reflection:

import inspect

caller = inspect.stack()[1][3]
# или
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
caller = calframe[1][3]

But this is not a good idea from the point of view of the architectural principles of software design.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question