Everyone at Class too big and hard to add new features is completely unphased by the question, which somehow connects command line options to methods, but I can find no documentation for this. It's not optparse
, or argparse
, or sys.argv
- the question implies some kind of direct relationship between methods and command line options. What am I missing?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
There isn't any set-in-stone link between them. The question you link to appears to be a program that can do one of several different things, with command-line arguments switching between them. These things happen to be implemented in the program using methods.
It is implied by the question that they have used something like
argparse
to write the glue between these; but the use of methods is just an implementation detail of the particular program.I simply use the class like this, what seems not to be a very good idea, because it is very hard to maintain once u got many commands.
EDIT1: Here a cleaner way I just implemented:
myprogram.py:
commands.py:
EDIT2: I have now updated my question you linked to your question with a more complete example Class too big and hard to add new features