Lichen

tests/attr_class.py

1037:2ef21d25c6e5
5 months ago Paul Boddie Merged changes from the default branch. trailing-data
     1 class SignalState:     2     Red = 1     3     Amber = 2     4     Green = 3     5     AmberAgain = 4     6     Off = None     7      8 class Signal:     9     def __init__(self):    10         self.disable()    11     12     def enable(self):    13         self.state = SignalState.Red    14     15     def disable(self):    16         self.state = SignalState.Off    17     18     def next(self):    19         if self.state == SignalState.Red:    20             self.state = SignalState.Amber    21         elif self.state == SignalState.Amber:    22             self.state = SignalState.Green    23         elif self.state == SignalState.Green:    24             self.state = SignalState.AmberAgain    25         elif self.state == SignalState.AmberAgain:    26             self.state = SignalState.Red    27         else:    28             self.state = SignalState.Off    29     30 s = Signal()    31 print s.state   # None    32 s.next()    33 print s.state   # None    34 s.enable()    35 print s.state   # 1    36 s.next()    37 print s.state   # 2    38 s.next()    39 print s.state   # 3    40 s.next()    41 print s.state   # 4    42 s.next()    43 print s.state   # 1