If you want to get this reference at a runtime, you can use inspect module in your class to get the python context around it. Here is small example:
# main.py
from utils import MyClass
my_class = MyClass()
my_class.get_the_fish()
# utils.py
import inspect
class MyClass:
def __init__(self):
frame = inspect.stack()[1] # one frame up the stack
print(f"class initialized from {frame.filename}:{frame.lineno}")
print(f"code: {frame.code_context}")
def get_the_fish(self):
print("got the fish!")
$ python main.py
class initialized from /Users/alice/codebase/main.py:3
code: ['my_class = MyClass()\n']
got the fish!