[Python-ideas] making a module callable

Ben Finney ben+python at benfinney.id.au
Tue Nov 26 01:46:08 CET 2013


Greg Ewing <greg.ewing at canterbury.ac.nz> writes:

> Ben Finney wrote:
> > Automatically discarding the first argument, on the assumption that
> > the program doesn't care about it, is making a false assumption in
> > many cases and makes a common use case needlessly difficult.
>
> If you're talking about doing different things based on argv[0], I
> wouldn't call it a *common* use case.

The common use case I'm referring to is to use the program name in
output messages (e.g. help, errors) without needing to change the code
when the program file is renamed, or when a different command line is
constructed by the caller.

Doing different things based on how the program is invoke is another
common use case, yes.

Both of these use cases argue for retaining the full command line
sequence (or whatever replacement command line sequence the caller
chooses to construct) as input to the main code, and allow the main code
to decide which parts are important.

-- 
 \      “I am too firm in my consciousness of the marvelous to be ever |
  `\       fascinated by the mere supernatural …” —Joseph Conrad, _The |
_o__)                                                     Shadow-Line_ |
Ben Finney



More information about the Python-ideas mailing list