'Get class file path from called class in Python

Imagine class B is in a main.py file and class A is in a package module. I would like inside the package to retrive the path of the calling class B. With "path" I mean the full system path of the file (for windows: C:\...)

class A:
  def func_a(self):
    print(f'path: {path}')

class B:
  def func_b(self):
    a = A()
    a.func_a()

b = B()
b.func_b()



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source