Function for the path of the script?
Grant Edwards
invalid at invalid.invalid
Mon Oct 28 10:58:12 EDT 2013
On 2013-10-27, Ben Finney <ben+python at benfinney.id.au> wrote:
> What workflow requires you to know the filename of the module, within
> the module?
If you have a utility that can be used to do several related things,
one way to tell that utility which you want to do is with command line
arguments. For example your utility checks sys.argv[1] for a command
or option flag. Another way is to give the file multiple names, and
check sys.argv[0] to see what name you've been invoked under. The
latter approach not unusual in the Unix world, and has been carried to
a rather astounding extent by the "busybox" project:
http://www.busybox.net/about.html
It's all the command-line utilities you need for a small Unix system
in a single binary: one executable with dozens and dozens of links
(hard or symbolic).
--
Grant Edwards grant.b.edwards Yow! I request a weekend in
at Havana with Phil Silvers!
gmail.com
More information about the Python-list
mailing list