[Python-ideas] making a module callable
Steven D'Aprano
steve at pearwood.info
Sat Nov 23 05:21:00 CET 2013
On Sat, Nov 23, 2013 at 12:21:41PM +1300, Greg Ewing wrote:
> >@mainfunction
> >def main(args):
> > assert args == sys.argv[1:]
>
> Now we can have an argument about whether args should include
> sys.argv[0] or not...
Of course it should :-)
I'm serious, by the way. It's a nice Unix trick to have a single
executable do different things depending on what name it is called by.
Inspecting argv[0] lets you do that.
--
Steven
More information about the Python-ideas
mailing list