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()

```
Unfortunately there is no flag/command-line option to enable that. So the immediate (and probably correct) answer is: **No**.

If you're okay with messing with the built-in libraries you can easily make it possible by changing the line that reads:

```
print (" --- modulename: %s, funcname: %s" 
       % (modulename, code.co_name))

```

with:

```
print ("filename: %s, modulename: %s, funcname: %s"
       % (filename, modulename, code.co_name))

```

in the `trace.py` file of your Python installation. You can find the path to that file with:

```
>>> import trace
>>> trace.__file__

```

But I really don't want to suggest that modifying libraries that way is something I would recommend. Before you do this (if you decide you really want to do that) create a backup of the file and if possible replace it again after you're done.

A better way (although still messy) is to copy the above mentioned `trace.py` file (for example into the current working directory) and modify the copied file. Then you can run the modified version:

```
python path_to_modified_trace_file your_options_for_trace

```

Without the `-m` option and with the modified path, but otherwise identical to your original.