Skip to main content

objerve

A tiny observer for the attributes of Python objects.

Actions Status GitHub issues GitHub stars GitHub license Downloads

Installation

objerve can be installed by running pip install objerve

Example Usage

Let's say you have a class like that;

class M:
    qux = "blue"

    def __init__(self):
        self.bar = 55
        self.foo = 89
        self.baz = 121

To watch the changes, you need the add the @watch() as a class decorator. Within the arguments of the watch decorator you should pass in lists for the keyword arguments of the attributes you wish to watch.

from objerve import watch

@watch(set={"foo", "qux"}, get={"bar", "foo"}, delete={"baz"})
class M:
    qux = "blue"

    def __init__(self):
        self.bar = 55
        self.foo = 89
        self.baz = 121


m = M()
m.bar = 233


def abc():
    m.foo += 10


m.qux = "red"


def get_foo(m):
    m.bar


abc()
m.foo
del m.baz
get_foo(m)

Output:

Set | foo = 89
  File "/home/blue/objerve/examples/example.py", line 9, in __init__
    self.foo = 89

Set | qux = red
  File "/home/blue/objerve/examples/example.py", line 21, in <module>
    m.qux = "red"

Get | foo
  File "/home/blue/objerve/examples/example.py", line 18, in abc
    m.foo += 10

Set | foo = 99
  File "/home/blue/objerve/examples/example.py", line 18, in abc
    m.foo += 10

Get | foo
  File "/home/blue/objerve/examples/example.py", line 29, in <module>
    m.foo

Delete | baz
  File "/home/blue/objerve/examples/example.py", line 30, in <module>
    del m.baz

Get | bar
  File "/home/blue/objerve/examples/example.py", line 25, in get_foo
    m.bar

Metadata

Release files for objerve 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for objerve 0.2.0
File Size Uploaded
objerve-0.2.0.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for objerve 0.2.0
File Interpreter ABI Platform
objerve-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / objerve-0.2.0.tar.gz

Download URL objerve-0.2.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b888fba69b7fb553e82fbfb07e9cc0946d3cea122076dbc8248772f62e96fbae
BLAKE2b-256 checksum
How to use checksums
915bcdce32fff36c8b78c06f16bcb9c962246863a10abc9d15dc49518c79e1eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / objerve-0.2.0-py3-none-any.whl

Download URL objerve-0.2.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18eae315200fa2b9e80b2c8ce9bfe37718e93d9eb59143ff696b378e32f1c589
BLAKE2b-256 checksum
How to use checksums
918d2dcb82571f66e0b3d64516375f96cf7e313d7cde60b3cefdaa1b6305d0f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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