Can Python Module Locate Itself?
Miki Tebeka
tebeka at cs.bgu.ac.il
Wed Sep 17 07:10:37 EDT 2003
Hello sj,
> I have written several small shell utilities in Python and typically use
> comments at the start of the source file as documentation. A command line
> option allows the user to read this documentation. The problem is that I
> have to explicitly code the source files location within the source which
> is not very portable. Is there anyway for a python module to locate its
> own source ?
sys.argv[0] is always the name of the script.
Have you looked at the new optparse module?
(http://www.python.org/doc/current/lib/module-optparse.html)
HTH.
Miki
More information about the Python-list
mailing list