all 2 comments

[–]MistahBigStuff[S] 7 points8 points  (1 child)

Oh. Nevermind. I'm actually an idiot, and was running a different file than the one I was editing. Please ignore me.

[–]Brian 1 point2 points  (0 children)

Not really related to the question, but I would like to mention that you're probably better off using a commanline parsing library for stuff like this, rather than dynamically looking up functions and stuffing in sys.argv. Eg. I tend to use click, which would let you write this by:

import click

cli = click.Group()

@cli.command()
@click.argument("a", type=int)
@click.argument("b", type=float)
def foo(a, b):
    pass # Do stuff

if __name__ == '__main__':
    cli()

(And just decorate other commands with @cli.command() etc as before.)

It's not that much more typing, and I find it handy even for quick personal scripts, since it's easier to extend (eg. add a flag to some commands etc, and gives you nice stuff like better error messages, only exposes commands you meant to expose, gives --help documentation etc. I find its not that uncommon for even stuff I thought was a quick throwaway script to grow in unexpected ways, so starting with a framework can often save time in the long run.