Skip to main content

PyPI Build Status Coverage Status

A simple implementation of the observer pattern.

import simpleobserver
# Create a subject and list the events it might fire
foo = simpleobserver.Subject('bar', 'baz')

# Add a listener
def foo_bar_listener(*args):
   print("heard 'bar'", args)

foo('bar', foo_bar_listener)

# fire events
foo.fire('bar', 1, 2, 3)
# -> heard 'bar' (1, 2, 3)

# Trying to listen to an unregistered event throws an error
foo('snorble', lambda: None)
# -> AssertionError: snorble is not a valid event for this subject

# Same with trying to fire an unregistered event
foo.fire('snorble')
# -> AssertionError: snorble is not a valid event for this subject

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpleobserver-1.0.3.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file simpleobserver-1.0.3.tar.gz.

File metadata

File hashes

Hashes for simpleobserver-1.0.3.tar.gz
Algorithm Hash digest
SHA256 b02bf8aac60f25388a58046d32866c864eb679ffa38e2d88964be1a2329b1f10
MD5 ed4852902b20792aa405a8aeab8c134f
BLAKE2b-256 06aea9a4e932d31bfd154f92a249f28fa35a1af68eff50c43ef895417c3660b9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.3 This release

1 file

1.0.2

1 file

1.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page