Movatterモバイル変換


[0]ホーム

URL:


Up one LevelPython Library ReferenceContentsModule IndexIndex


14.3.3.2 Populating the parser

There are several ways to populate the parser with options. Thepreferred way is by usingOptionParser.add_option(), as shown insection 14.3.2, the tutorial.add_option() can be called in one of twoways:

The other alternative is to pass a list of pre-constructed Optioninstances to the OptionParser constructor, as in:

option_list = [    make_option("-f", "--filename",                action="store", type="string", dest="filename"),    make_option("-q", "--quiet",                action="store_false", dest="verbose"),    ]parser = OptionParser(option_list=option_list)

(make_option() is a factory function for creating Option instances;currently it is an alias for the Option constructor. A future versionofoptparse may split Option into several classes, andmake_option()will pick the right class to instantiate. Do not instantiate Optiondirectly.)


Up one LevelPython Library ReferenceContentsModule IndexIndex

Release 2.5.2, documentation updated on 21st February, 2008.
SeeAbout this document... for information on suggesting changes.
[8]ページ先頭

©2009-2025 Movatter.jp