[Python-ideas] making a module callable

Stephen J. Turnbull stephen at xemacs.org
Tue Nov 26 02:32:29 CET 2013


Greg Ewing writes:

 > If you're talking about doing different things based on
 > argv[0], I wouldn't call it a *common* use case. The last
 > time I saw it done was on an early version of SunOS that
 > didn't have shared libraries, so they linked all the gui
 > tools into one big executable to reduce disk and memory
 > usage.

busybox is still standard in many Linux distros, though I don't really
know why (embedded systems, "small" rescue media?), and surely you've
seen fgrep/grep/egrep (hardlinked to the same file on Mac OS X as of
"Snow Leopard"), even if you personally use POSIX-standard "grep -F"
and "grep -E".

Linking /bin/sh to bash or zsh is a common trick on GNU systems, and
typically invokes strict POSIX conformance (well, as strictly as any
GNU program ever conforms to another organization's standard :-( ).

So I rather suspect you "see" it frequently, even today.  You just
don't recognize it when you see it.

Could we do without such trickery?  Sure.  However, the point about
usage messages still stands: it's useful to fetch the actual command
line token used to invoke the program, because program names and
invocation methods do change.





More information about the Python-ideas mailing list