What does dry-run do in optparse Python?
What's the functionality of the dry-run
option in the optparse mod开发者_如何学Pythonule of Python?
Dry run is a generic expression in many fields, including computing, meaning that a certain operation should be performed or simulated limiting its dangerous effects.
It is up to you to associate that option to something meaningful in your code. For example: if your script normally removes files from the hard drive, the --dry-run
option should only print out a list of the files that would have been deleted if the script would have been ran without the --dry-run
option.
--dry-run
is just a conventional name for that option, but you could implement the same functionality with any other name (e.g --simulate-only
or --dont-screw-up
).
--dry-run
has no special meaning for the optparse
module.
It is just an example used in the documentation of the module.
精彩评论