Movatterモバイル変換


[0]ホーム

URL:


Up one LevelPython Library ReferenceContentsModule IndexIndex


14.3.3.6 Standard option types

optparse has six built-in option types:string,int,long,choice,float andcomplex. If you need to add new optiontypes, see section 14.3.5, Extendingoptparse.

Arguments to string options are not checked or converted in any way: thetext on the command line is stored in the destination (or passed to thecallback) as-is.

Integer arguments (typeint orlong) are parsed as follows:

The conversion is done by calling eitherint() orlong() withthe appropriate base (2, 8, 10, or 16). If this fails, so willoptparse,although with a more useful error message.

float andcomplex option arguments are converted directly withfloat() andcomplex(), with similar error-handling.

choice options are a subtype ofstring options. Thechoicesoption attribute (a sequence of strings) defines the set of allowedoption arguments.optparse.check_choice() comparesuser-supplied option arguments against this master list and raisesOptionValueError if an invalid string is given.


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