Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
An immutable condition class, instances of which have state determined by some
predicate.  Instances of this class have no way to know when their state should be
recomputed, so you need to actively C{L{update}} it.  For an automated way, see
C{L{AbstractVariable.predicate <variable.AbstractVariable.predicate>}} method.

Predicate conditions remember their state, so C{predicate} is called only from

were updated for.

Advantage of using predicate conditions over all-purpose mutable ones and setting its(more...)

src/p/y/py-notify-0.3.1/test/condition.py   py-notify(Download)
import operator
 
from notify.condition import AbstractCondition, AbstractStateTrackingCondition, Condition, \
                             PredicateCondition, WatcherCondition
from notify.variable  import Variable
    def test_predicate_condition_1 (self):
        test = NotifyTestObject ()
 
        predicate = PredicateCondition (bool, None)
        predicate.store (test.simple_handler)
    def test_predicate_condition_2 (self):
        test = NotifyTestObject ()
 
        predicate = PredicateCondition (bool, None)
        predicate.store (test.simple_handler)
    def test_predicate_condition_3 (self):
        test = NotifyTestObject ()
 
        predicate = PredicateCondition (lambda x: x > 10, 0)
        predicate.store (test.simple_handler)
    def test_predicate_condition_error_2 (self):
        self.assertRaises (ZeroDivisionError, lambda: PredicateCondition (lambda x: 1/x, 0))
 
        predicate = PredicateCondition (lambda x: 1/x, 10)
        self.assertRaises (ZeroDivisionError, lambda: predicate.update (0))