On Thu, 11 Aug 2016 11:23 pm, Cecil Westerhof wrote: > It has been a while since I worked with Python. I wanted to get some > stats about the idle time of my computer, so that was a good moment to > pick up Python again. ;-) > > > As I understood it getopt is the way to get the parameters for your > script.
getopt is mainly for C programmers from Unix or Linux systems who are used to using the Unix getopt function for handling parameters. There are two alternatives in the standard library: optparse (depreciated, for legacy use only) argparse https://docs.python.org/3/library/getopt.html https://docs.python.org/3/library/optparse.html https://docs.python.org/3/library/argparse.html and many third-party options, including DocOpt: https://pypi.python.org/pypi/docopt [...] > Is this acceptable, or is it a big no-no? Despite what Peter says, the Python police won't come after you. Your punishment for writing hard-to-maintain code is that you have to maintain your own hard-to-maintain code. If you have only a few command line arguments, and they don't change often, the effort required to learn the "right" way to process them may be significantly harder than the effort required to do it the "wrong" way. That's called "technical debt", and in an on-going software project it can hurt you very, very much. Technical debt can cause software projects to fail. But for personal use, where your software tends to be small and simple, don't feel guilty about it. You'll know when it's time to learn one of the other argument parsers: when you find yourself cursing the fact that you have to edit your own argument-parsing code, that's the time to bite the bullet and learn them. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list