os.path.dirname(sys.argv[0]) always returns nothing

Chris Angelico rosuav at gmail.com
Mon Aug 1 20:01:08 CEST 2011


On Mon, Aug 1, 2011 at 6:55 PM, Thijs Engels <thijs at buckazoids.com> wrote:
> argv[0] returns the name of the current file (string), but no path
> information if I recall correct.

It will give path information if you're invoking a script from another
directory. Under some circumstances it might happen to give an
absolute path for something in the current directory, but that can't
be assumed or relied upon.

ChrisA



More information about the Python-list mailing list