Python calling files from ancestor directories?
Hi there, Any idea how I can use Python to call a file two directories up? So if my python script is at: /root/blah/cgi/someScript And I want it to return the file: /root/nah/someFile I haven't figured out how to do this yet, any ideas? Alec Munro
BTW: Does anyone else find a folder full of Python scripts named cgi at all troubling? Anyhow, there is a method you can acquire to get the root. Here is a sample: root = container.getPhysicalRoot() some_file = root.nah.someFile ... hth, Casey On Wed, 2002-06-12 at 10:33, Alec Munro wrote:
Hi there, Any idea how I can use Python to call a file two directories up? So if my python script is at: /root/blah/cgi/someScript
And I want it to return the file: /root/nah/someFile
I haven't figured out how to do this yet, any ideas?
Alec Munro
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Alec Munro writes:
Any idea how I can use Python to call a file two directories up? So if my python script is at: /root/blah/cgi/someScript
And I want it to return the file: /root/nah/someFile What do you mean with "call" or "return"?
I assume you are in a Python Script. Then you can (usually) access "root.nah.someFile" by "context.nah.someFile". In order for this to work, "/root/nah" must be "nearest" (with respect to acquisition search order) "nah" to "context". It would, e.g., not work from "/root/blah/nah/someScript". Dieter
participants (3)
-
Alec Munro -
Casey Duncan -
Dieter Maurer