I am originally a C programmer. I have seen numerous tricks and \"hacks\" to read many different arguments.
What are some of the ways Python programmers can do this
The docopt library is really slick. It builds an argument dict from the usage string for your app.
Eg from the docopt readme:
"""Naval Fate.
Usage:
naval_fate.py ship new ...
naval_fate.py ship move [--speed=]
naval_fate.py ship shoot
naval_fate.py mine (set|remove) [--moored | --drifting]
naval_fate.py (-h | --help)
naval_fate.py --version
Options:
-h --help Show this screen.
--version Show version.
--speed= Speed in knots [default: 10].
--moored Moored (anchored) mine.
--drifting Drifting mine.
"""
from docopt import docopt
if __name__ == '__main__':
arguments = docopt(__doc__, version='Naval Fate 2.0')
print(arguments)