I am looking for something like the caller() routine in Perl: http://perldoc.perl.org/functions/caller.html
I am writing a script which needs to be allocated an object containing a set of paths that it will use for reading and writing during it's execution: import os.path class logic: def __init__(self): std_dirs = "in out zip arc".split() self.root = os.path.dirname(__main__.__file__) # doesnt work for d in std_dirs: mkdir = "%s/%s" % (self.root, d) os.mkdir(mkdir) setattr(self, d, mkdir) # Then the script can do this: directories = data.storage.logic() infile = "%s/%s" % (directories.in, "infile") f = open (infile, 'r') # Of course I could cheat and pass it, but I don't want to: directories = data.storage.logic(__file__) -- http://mail.python.org/mailman/listinfo/python-list