class C1 is in file F1 which is in directory D1.
class C2, which inherits from C1, is in file F2 which is in directory D2.
The location of D2 is arbitrary (ie: it can't be hardcoded).
C1's method m_1() (inherited by C2) must open files relative to D2
F2.main() must be able to be run both directly (from script or Windows) as well as via "import mypackage.F2 as f; f.main()". Running directly causes no problems with relative opens; importing and calling main(), however, tries to open relative to the current working directory.
Unfortunately __file__ is only provided when the script is not executed.
Currently I'm putting this monstrosity at the start of F2's main():
I've made no headway with getting inspect.py to work (getabspath() would be handy but it just doesn't appear to like newstyle objects)
Is there a better way to determine in which file/directory a particular object was created in?