Skip to content

glue-viz/echo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2a7664b · Jan 29, 2025
Jan 29, 2025
Apr 11, 2020
Jul 19, 2024
Jan 18, 2017
Apr 10, 2020
Apr 10, 2020
Jul 19, 2024
Mar 13, 2014
Mar 13, 2014
Apr 11, 2020
Mar 13, 2014
Jun 4, 2024
Apr 10, 2020
Jan 29, 2025

Repository files navigation

Azure Status Coverage Status

echo: Callback Properties in Python

Echo is a small library for attaching callback functions to property state changes. For example:

class Switch(object):
    state = CallbackProperty('off')

def report_change(state):
    print 'the switch is %s' % state

s = Switch()
add_callback(s, 'state', report_change)

s.state = 'on'  # prints 'the switch is on'

CalllbackProperties can also be built using decorators

class Switch(object):

      @callback_property
      def state(self):
        return self._state

      @state.setter
      def state(self, value):
          if value not in ['on', 'off']:
              raise ValueError("invalid setting")
          self._state = value

Full documentation is avilable here