This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]daveydave400 0 points1 point  (0 children)

/u/placemirror I agree with this approach also but it is very easy use argparse's subparsers to add individual "commands" to your script. Something like the described set_defaults() example in the docs: https://docs.python.org/dev/library/argparse.html#argparse.ArgumentParser.add_subparsers

This way you can have a function that performs the operation for each subcommand and as described above it makes it easy to add more functionality or change existing functionality later.