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
Metadata
Release files for simpleobserver 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| simpleobserver-1.0.3.tar.gz | 2.0 kB | Without provenance | Details |
Release files / simpleobserver-1.0.3.tar.gz
| Download URL | simpleobserver-1.0.3.tar.gz |
|---|---|
| Size | 2.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b02bf8aac60f25388a58046d32866c864eb679ffa38e2d88964be1a2329b1f10
|
|
BLAKE2b-256 checksum How to use checksums |
06aea9a4e932d31bfd154f92a249f28fa35a1af68eff50c43ef895417c3660b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for simpleobserver 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.