skip to navigation
skip to content

observed 0.2.4

Observer pattern for functions and bound methods

Latest Version: 0.4

observed allows you to to sign up functions or methods to "observe" other
functions or methods:

from observed import event

class Foo(object):
def __init__(self, name): = name

def bar(self, arg):
print("Object %s invoked bar with arg='%s'"%(,arg))

def callback(arg):
print("callback was invoked with arg='%s'"%(arg,))

a = Foo('a')
b = Foo('b')
# Sign up and callback to "observe"
# Now when we call, will be invoked with the same arguments'baz')

>>> Object a invoked bar with arg='baz'
>>> Object b invoked bar with arg='baz'
>>> callback was invoked with arg='baz'

This example is included in ./observed/

You can also ask that the observed object pass itself as the first argument
whenever it calls observers:

from observed import event

def observed_func():
print("observed_func: I was called")

def observer_func(observed):
print("observer_func: %s called me"%(observed.__name__,))

observed_func.addObserver(observer_func, identifyObserved=True)

>>> observed_func: I was called
>>> observer_func: observed_func called me

Notable features include:

1. Being an observer does not keep an object alive. In other words, the
observer code does not keep any strong references to objects which
have signed up as observers.
2. The @event decorator can be used with unhashable types, and can be
used on an arbitrary number of methods in each class.
3. Tests included :)


pip install observed


Unpack the source distribution.
Navigate to the root directory of the unpacked distribution.
At command prompt:
python install


See the file NEWS for the user-visible changes from previous releases.


observed is free (as in beer) software. See the LICENSE file.


observed can be obtained from the python package index

or via git


Basic usage is illustrated at the top of this file. Further examples are
given in ./observed/

The source code is documented. Docstrings are required in contributions.


observed development is hosted on github. The current working repository
is given in the Downloading section above.

Bug Reporting

Please submit bug tickets on the github tracking system  
File Type Py Version Uploaded on Size (md5) Source 2014-05-26 7KB