program path
Steven Taschuk
staschuk at telusplanet.net
Sun Jun 8 15:59:19 EDT 2003
Quoth Peter Hansen:
[...]
> See Mike's reply... it works fine.
Good to know.
> So basically os.path.abspath(sys.argv[0]) should be the idiomatic
> way to find the full path where the __main__ script lives.
I notice the alternative
sys.modules['__main__'].__file__
which I like because it generalizes easily to arbitrary modules,
as the sys.argv[0] approach does not. Does this alternative have
any disadvantages I'm not seeing?
--
Steven Taschuk staschuk at telusplanet.net
"I may be wrong but I'm positive." -- _Friday_, Robert A. Heinlein
More information about the Python-list
mailing list