Given a class C in Python, how can I determine which file the class was defined in? I need something that can work from either the class C, or from an instance off C.
You can use the inspect module, like this:
import inspect inspect.getfile(C.__class__)