Belle II Software development
NonstrictChoices Class Reference
Inheritance diagram for NonstrictChoices:

Public Member Functions

def __contains__ (self, value)
 
def __iter__ (self)
 
def __str__ (self)
 

Detailed Description

Class that instances can be given to an argparse.ArgumentParser.add_argument as choices keyword argument.

The explicit choices stated during construction of this object are just suggestions but all other values are
excepted as well.

Definition at line 32 of file utilities.py.

Member Function Documentation

◆ __contains__()

def __contains__ (   self,
  value 
)
Test for correctness of the choices.
Always returns true since all choices should be valid not only the ones stated at construction of this object.

Definition at line 40 of file utilities.py.

40 def __contains__(self, value):
41 """Test for correctness of the choices.
42 Always returns true since all choices should be valid not only the ones stated at construction of this object.
43 """
44 return True
45

◆ __iter__()

def __iter__ (   self)
Displays all explicit values and a final "..." to indicate more choices might be possible.

Definition at line 46 of file utilities.py.

46 def __iter__(self):
47 """Displays all explicit values and a final "..." to indicate more choices might be possible."""
48 # Append an ellipses to indicate that there are more choices.
49 copy = list(super().__iter__())
50 copy.append('...')
51 return iter(copy)
52

◆ __str__()

def __str__ (   self)
Displays all explicit values and a final "..." to indicate more choices might be possible.

Definition at line 53 of file utilities.py.

53 def __str__(self):
54 """Displays all explicit values and a final "..." to indicate more choices might be possible."""
55 # Append an ellipses to indicate that there are more choices.
56 copy = list(self)
57 copy.append('...')
58 return str(copy)
59
60

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