Package _Framework :: Module Util :: Class BooleanContext
[hide private]
[frames] | no frames]

Class BooleanContext

source code

object --+
         |
        BooleanContext

This class represents an boolean variable with RAII setting within a scope. It is useful to break recursions in an exception-safe way. The boolean context can be used in nested fashion, as long as you request a new context manager for every 'with' statement using the call operator. Example:

 in_notification = BooleanContext()

 assert not in_notification
 with in_notification():
     assert in_notification
     with in_notification():
         assert in_notification
     assert in_notification
 assert not in_notification

The 'default_value' parameter indicates the initial value. It will be negated when you enter the context.

Nested Classes [hide private]
  Manager
Instance Methods [hide private]
 
__init__(self, default_value=None, *a, **k)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__nonzero__(self) source code
 
__bool__(self) source code
 
__call__(self)
Makes a context manager for the boolean context
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  default_value = False
Properties [hide private]
  value

Inherited from object: __class__

Method Details [hide private]

__init__(self, default_value=None, *a, **k)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

Property Details [hide private]

value

Get Method:
unreachable.value(self)