Nektar++
Public Member Functions | Private Attributes | List of all members
CellMLToNektar.utilities.Sentinel Class Reference
Inheritance diagram for CellMLToNektar.utilities.Sentinel:
[legend]

Public Member Functions

def __init__ (self, tf=False)
 
def __nonzero__ (self)
 
def set (self, tf=True)
 

Private Attributes

 _tf
 

Detailed Description

A simple true/false store that can be used as a default parameter value in recursive calls.

This provides a slightly nicer looking alternative to code such as:

def f(done=[False]):
   if not done[0]:
       # do some stuff
       if xyz: done[0] = True
       f(done)

The list can be replaced with a Sentinel instance.

Definition at line 142 of file utilities.py.

Constructor & Destructor Documentation

◆ __init__()

def CellMLToNektar.utilities.Sentinel.__init__ (   self,
  tf = False 
)
Create a new, unset sentinel.

Definition at line 155 of file utilities.py.

155 def __init__(self, tf=False):
156 """Create a new, unset sentinel."""
157 self._tf = tf
158

Member Function Documentation

◆ __nonzero__()

def CellMLToNektar.utilities.Sentinel.__nonzero__ (   self)
Test whether the sentinel has been set.

Definition at line 159 of file utilities.py.

159 def __nonzero__(self):
160 """Test whether the sentinel has been set."""
161 return self._tf
162

References CellMLToNektar.utilities.Sentinel._tf.

◆ set()

def CellMLToNektar.utilities.Sentinel.set (   self,
  tf = True 
)
Set the sentinel.

Definition at line 163 of file utilities.py.

163 def set(self, tf=True):
164 """Set the sentinel."""
165 self._tf = tf
166
167

References CellMLToNektar.utilities.Sentinel._tf.

Member Data Documentation

◆ _tf

CellMLToNektar.utilities.Sentinel._tf
private