class documentation

class Argument: (source)

View In Hierarchy

A command-line argument/flag. :param name: Syntactic sugar for ``names=[<name>]``. Giving both ``name`` and ``names`` is invalid. :param names: List of valid identifiers for this argument. For example, a "help" argument may be defined with a name list of ``['-h', '--help']``. :param kind: Type factory & parser hint. E.g. ``int`` will turn the default text value parsed, into a Python integer; and ``bool`` will tell the parser not to expect an actual value but to treat the argument as a toggle/flag. :param default: Default value made available to the parser if no value is given on the command line. :param help: Help text, intended for use with ``--help``. :param positional: Whether or not this argument's value may be given positionally. When ``False`` (default) arguments must be explicitly named. :param optional: Whether or not this (non-``bool``) argument requires a value. :param incrementable: Whether or not this (``int``) argument is to be incremented instead of overwritten/assigned to. :param attr_name: A Python identifier/attribute friendly name, typically filled in with the underscored version when ``name``/``names`` contain dashes. .. versionadded:: 1.0

Method __init__ Undocumented
Method __repr__ Undocumented
Method set_value Actual explicit value-setting API call.
Method value.setter Undocumented
Instance Variable attr_name Undocumented
Instance Variable default Undocumented
Instance Variable help Undocumented
Instance Variable incrementable Undocumented
Instance Variable kind Undocumented
Instance Variable names Undocumented
Instance Variable optional Undocumented
Instance Variable positional Undocumented
Instance Variable raw_value Undocumented
Property got_value Returns whether the argument was ever given a (non-default) value.
Property name The canonical attribute-friendly name for this argument.
Property nicknames Undocumented
Property takes_value Undocumented
Property value Undocumented
Instance Variable _value Undocumented
def __init__(self, name=None, names=(), kind=str, default=None, help=None, positional=False, optional=False, incrementable=False, attr_name=None): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def set_value(self, value, cast=True): (source)

Actual explicit value-setting API call. Sets ``self.raw_value`` to ``value`` directly. Sets ``self.value`` to ``self.kind(value)``, unless: - ``cast=False``, in which case the raw value is also used. - ``self.kind==list``, in which case the value is appended to ``self.value`` instead of cast & overwritten. - ``self.incrementable==True``, in which case the value is ignored and the current (assumed int) value is simply incremented. .. versionadded:: 1.0

@value.setter
def value(self, arg): (source)

Undocumented

attr_name = (source)

Undocumented

Undocumented

Undocumented

incrementable = (source)

Undocumented

Undocumented

Undocumented

optional = (source)

Undocumented

positional = (source)

Undocumented

raw_value = (source)

Undocumented

Returns whether the argument was ever given a (non-default) value. For most argument kinds, this simply checks whether the internally stored value is non-``None``; for others, such as ``list`` kinds, different checks may be used. .. versionadded:: 1.3

The canonical attribute-friendly name for this argument. Will be ``attr_name`` (if given to constructor) or the first name in ``names`` otherwise. .. versionadded:: 1.0

Undocumented

@property
takes_value = (source)

Undocumented

Undocumented

Undocumented