Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_argparse.TestActionUserDefined.PositionalAction Class Reference
Inheritance diagram for test.test_argparse.TestActionUserDefined.PositionalAction:
Inheritance graph
[legend]
Collaboration diagram for test.test_argparse.TestActionUserDefined.PositionalAction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __call__
def __repr__

Public Attributes

 dest
 option_strings
 nargs
 const
 default
 type
 choices
 required
 help
 metavar
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Definition at line 1648 of file test_argparse.py.


Member Function Documentation

def test.test_argparse.TestActionUserDefined.PositionalAction.__call__ (   self,
  parser,
  namespace,
  value,
  option_string = None 
)

Reimplemented from argparse.Action.

Definition at line 1650 of file test_argparse.py.

01650 
01651         def __call__(self, parser, namespace, value, option_string=None):
01652             try:
01653                 assert option_string is None, ('option_string: %s' %
01654                                                option_string)
01655                 # check destination
01656                 assert self.dest == 'badger', 'dest: %s' % self.dest
01657                 # when argument is before option, spam=0.25, and when
01658                 # option is after argument, spam=<whatever was set>
01659                 expected_ns = NS(badger=2)
01660                 if value in [42, 84]:
01661                     expected_ns.spam = 0.25
01662                 elif value in [1]:
01663                     expected_ns.spam = 0.625
01664                 elif value in [2]:
01665                     expected_ns.spam = 0.125
01666                 else:
01667                     raise AssertionError('value: %s' % value)
01668                 assert expected_ns == namespace, ('expected %s, got %s' %
01669                                                   (expected_ns, namespace))
01670             except AssertionError:
01671                 e = sys.exc_info()[1]
01672                 raise ArgumentParserError('arg_action failed: %s' % e)
01673             setattr(namespace, 'badger', value)
01674 
    argument_signatures = [
def argparse._AttributeHolder.__repr__ (   self) [inherited]

Definition at line 121 of file argparse.py.

00121 
00122     def __repr__(self):
00123         type_name = type(self).__name__
00124         arg_strings = []
00125         for arg in self._get_args():
00126             arg_strings.append(repr(arg))
00127         for name, value in self._get_kwargs():
00128             arg_strings.append('%s=%r' % (name, value))
00129         return '%s(%s)' % (type_name, ', '.join(arg_strings))

Here is the call graph for this function:


Member Data Documentation

Definition at line 780 of file argparse.py.

argparse.Action.const [inherited]

Definition at line 777 of file argparse.py.

Definition at line 778 of file argparse.py.

Reimplemented from argparse.Action.

Definition at line 1655 of file test_argparse.py.

argparse.Action.help [inherited]

Definition at line 782 of file argparse.py.

Definition at line 783 of file argparse.py.

argparse.Action.nargs [inherited]

Definition at line 776 of file argparse.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 774 of file argparse.py.

Definition at line 781 of file argparse.py.

argparse.Action.type [inherited]

Definition at line 779 of file argparse.py.


The documentation for this class was generated from the following file: