Hah *goes to run 

Sent from my iPhone

On Aug 25, 2009, at 10:59 AM, Kevin Dwyer <kevin@pheared.net> wrote:

Shhhh!  I was trying to guide David _away_ from things like sys._getframe().  :-)

-kpd

On Tue, Aug 25, 2009 at 10:23 AM, Eric Smith <eric@trueblade.com> wrote:
If you want to know who called you, look at sys._getframe(). Lots of people consider using sys._getframe() an anti-pattern, and in addition it isn't supported by IronPython or Jython. That said, I occasionally use it for a quick and dirty hack.

Eric.

J.L. Ennis wrote:
David -

You can figure out the name of the module with the __name__ built-in variable or the path of the module with __file__.

To find the xml files, you can using os.walk (if you have python 2.6) http://docs.python.org/library/os.html#os.walk or os.path.walk: http://docs.python.org/library/os.path.html#module-os.path

Hope this helps.

-Jennifer
- Hide quoted text -

On Tue, Aug 25, 2009 at 9:33 AM, David Greisen <dgreisen@gmail.com <mailto:dgreisen@gmail.com>> wrote:

   I want to be able to open and parse different xml files (all named
   the same) depending on which class calls the xml parser.
   I have a file structure that looks something like this:

   ./main.py
   ./module1/main.py
   ./module1/settings.xml
   ./module2/main.py
   ./module2/settings.xml
   ./module3/main.py
   ??/tools/xmlParser.py
   ??/tools/defaults.xml

   ./ is my initial working directory. main.py imports module1 and
   module2, which each import xmlParser and create a parser. I would
   like the parser to  look for an xml file in the folder of the code
   that called the tool, if it's not there, then it will use the
   default xml in its own folder.
   1) How do I figure out the name of the module that is making the
   call so I can then get to that folder.

   2) How do I call an xml file from a folder for which I do not have
   an absolute or relative path?

   Thanks in advance,

   David



--
To unsubscribe send an email with subject 'unsubscribe' to zpugdc@lists.zpugdc.org.
Please contact zpugdc-owner@lists.zpugdc.org for questions.
http://zpugdc.org/lists/zpugdc/archive/2009/2009-08/1251206730135/1251209699743