Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
CellMLToNektar.utilities.Sentinel Class Reference
Inheritance diagram for CellMLToNektar.utilities.Sentinel:
Inheritance graph
[legend]
Collaboration diagram for CellMLToNektar.utilities.Sentinel:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def __nonzero__
 
def set
 

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

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

Definition at line 155 of file utilities.py.

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

Member Function Documentation

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

Definition at line 159 of file utilities.py.

References CellMLToNektar.utilities.Sentinel._tf.

160  def __nonzero__(self):
161  """Test whether the sentinel has been set."""
162  return self._tf
def CellMLToNektar.utilities.Sentinel.set (   self,
  tf = True 
)
Set the sentinel.

Definition at line 163 of file utilities.py.

References CellMLToNektar.utilities.Sentinel._tf.

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

Member Data Documentation

CellMLToNektar.utilities.Sentinel._tf
private

Definition at line 157 of file utilities.py.

Referenced by CellMLToNektar.utilities.Sentinel.__nonzero__(), and CellMLToNektar.utilities.Sentinel.set().