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 29 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 37 of file utilities.py.

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

◆ __iter__()

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

Definition at line 43 of file utilities.py.

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

◆ __str__()

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

Definition at line 50 of file utilities.py.

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

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