Class KeywordOrBooleanArg
source code
Arg --+
|
KeywordOrBooleanArg
Allow a keyword arg to be specified either as a keyword or a boolean.
This arg type is the most flexible way to allow keyword parameters
to be specified. Say there is an option like 'fontsize' that can
take the values 'small' or 'large'. This could be represented as
'KeywordOrBooleanArg(options=["small", "large"], argname="fontsize")'
In that case, the fontsize could be specified in any of the
following ways:
'g.hardcopy(..., fontsize="small", ...)'
'g.hardcopy(..., fontsize="large", ...)'
'g.hardcopy(..., small=1, ...)'
'g.hardcopy(..., large=1, ...)'
If 'argname' is set to be 'None', then the first two possibilities
are omitted.
In the special case that there are exactly two alternatives, one
can also use:
'g.hardcopy(..., small=0, ...) # implies fontsize="large"'
'g.hardcopy(..., large=0, ...) # implies fontsize="small"'
Obviously care must be taken to ensure that none of the implied
keyword parameter names conflict with one another or with any of
the other Args allowed by a function.
Members:
'options' -- a list of strings representing allowed keyword
values. These options can be used as boolean values in
the style 'option=1'.
'argname' -- the name of the argname for the 'arg=value' style
of setting the argument. If 'None', then this style is
not allowed.
'fixedword' -- a fixed keyword that must precede the option,
or 'None'.
'default' -- the default option to set if nothing is set
explicitly, or None to leave nothing set in that case.
|
__init__(self,
options,
argname=None,
fixedword=None,
default=None) |
source code
|
|
|
|