Given a class C in Python, how do you determine in which file the class was defined? I need something that can work either from class C or from an instance with C.
The reason I do this is because I'm generally a fan of posting files that belong to each other in the same folder. I want to create a class that uses a Django template to display itself as HTML. The base implementation should output the file name for the template based on the name of the file in which this class is defined.
Let's say I put the LocationArtifact class in the file "base / artifacts.py", then I want the default name to be specified is "base / LocationArtifact.html".
python class introspection
Staale Mar 30 '09 at 13:58 2009-03-30 13:58
source share