Find directory name of file?
Blair P. Houghton
blair.houghton at gmail.com
Mon Jan 30 21:25:31 CET 2006
Grant Edwards wrote:
> Try something like this at the beginning of your program and
> see if it does what you want:
> print os.path.abspath(sys.argv)
Wanna see something freaky?
In IDLE, I type the following:
>>> import sys
>>> import os.path
Pretty normal, right? Then I type this:
>>> print sys.argv
Yup. No output. Even if I wrap the sys.argv in something visible,
there's nothing there:
>>> print "x"+str(sys.argv)+"y"
How does it know what the path of the argument is if it doesn't know
what the argument is? Seems a bit presumptive to assume that CWD is
the path to a blank string...unless abspath presumes that anything you
pass it is an executable, even if it's got no bytes...
More information about the Python-list