Question: I am tracing a python script like this:

```
python -m trace --ignore-dir=$HOME/lib64:$HOME/lib:/usr -t bin/myscript.py

```

Some lines look like this:

```
 --- modulename: __init__, funcname: getEffectiveLevel
__init__.py(1325):         logger = self
__init__.py(1326):         while logger:
__init__.py(1327):             if logger.level:
__init__.py(1329):             logger = logger.parent
__init__.py(1326):         while logger:
__init__.py(1327):             if logger.level:
__init__.py(1328):                 return logger.level

```

Unfortunately I have no clue where this code comes from.

Is there a way to see the file name (including the path) of `getEffectiveLevel()`?

Of course I could search through all installed python code for a method with this name, but I would like to see the file path immediately. 

In this context **Python 2.7** gets used.

> 
> I am not fixed to the standard library "trace". I could use a different library, if it provides the needed feature. 
> 
> 
>

Answer: 
if the purpose is finding the full path, then check [hunter](https://python-hunter.readthedocs.io/en/latest/readme.html#id1) project, it even has support for [query-style](https://python-hunter.readthedocs.io/en/latest/cookbook.html) tracing.

```
# a modified example from docs
# do check the documentation it is easy to start with
from hunter import trace, Q, Debugger
from pdb import Pdb

trace(
    # drop into a Pdb session on``myscript.mainMethod()`` call
    Q(module="myscript", function="getEffectiveLevel", kind="call", action=Debugger(klass=Pdb)))

import myscript
myscript.mainMethod()

```
You can create a `trace2.py` file with below content

```
from trace import Trace, main

original_globaltrace_lt = Trace.globaltrace_lt

def patch_Trace_globaltrace_lt(self, frame, why, arg):
    value = original_globaltrace_lt(self, frame, why, arg)
    if value:
        filename = frame.f_globals.get('__file__', "")
        print("The code is in file - %s" % (filename))
    return value

Trace.globaltrace_lt = patch_Trace_globaltrace_lt

if __name__ == "__main__":
    main()

```

and then run it like below

```
python -m trace2 --ignore-dir=$HOME/lib64:$HOME/lib:/usr -t bin/myscript.py

```

The output is verbose but you can alter the function `patch_Trace_globaltrace_lt` as per your needs