I have a module which needs to know what directory it's in, and to refer to files in a sibling directory, something like App/src/foo.py wants to read App/data/conf.xml . But I have no idea in what context foo.py is going to be run -- it could be being run as a script, it could be being imported as a module by another script from anywhere in the directory structure, it's even possible someone will have called execfile on it. The following works for everything I've tried:
thisdir = os.path.dirname(os.path.normpath(__file__)) siblingdir = os.path.normpath(os.path.join(testdir, os.path.pardir, "sibling")) However, a colleague expressed disgust at this code, but not really being a Python programmer had no better suggestions. Is there a neater way of getting what I want? -- \S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/ ___ | "Frankly I have no feelings towards penguins one way or the other" \X/ | -- Arthur C. Clarke her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- http://mail.python.org/mailman/listinfo/python-list