[Python-ideas] making a module callable

Chris Angelico rosuav at gmail.com
Tue Nov 26 00:54:28 CET 2013


On Tue, Nov 26, 2013 at 10:43 AM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> 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 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.

Upstart has a set of symlinks to initctl called "start", "stop",
"reload", etc. They're shortcuts for "initctl start", "initctl stop",
etc. Also, I've often fetched up argv[0] as part of a usage message,
which isn't strictly "doing different things", but it does mean that
renaming the program won't leave an old name inside its help message.

ChrisA


More information about the Python-ideas mailing list