Skip to main content

Tiny observer for the attributes of Python objects.

Project description

objerve

A tiny observer for the attributes of Python objects.

GitHub issues GitHub stars GitHub license

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 and watch_dict as a class variable.

watch_dict keys should be selected from __init__ or class variables and the values can be defined as a set, get and del. from objerve import watch

@watch
class M:
    watch_dict = {"foo": "set", "bar": "get", "baz": "del", "qux": "set"}
    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()
del m.baz
get_foo(m)

Output:

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

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

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

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

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

Project details


Download files

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

Source Distribution

objerve-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

objerve-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file objerve-0.1.0.tar.gz.

File metadata

  • Download URL: objerve-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.5

File hashes

Hashes for objerve-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02d31f436c9cada8374896b37fa47d1a6237644fe8d8c51f19aed5fbbd171000
MD5 c81ebbce8f7d11f429195be818cf510e
BLAKE2b-256 cab01714d462230c9579259e57e12a6df0e07372b6e9711c0bae7ba4839a7fae

See more details on using hashes here.

File details

Details for the file objerve-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: objerve-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.5

File hashes

Hashes for objerve-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4af9cefbc3f60a420eeaac3df3edbc1c6f66750eb62024a9a593c559c2c8802
MD5 06b677889de0e391739b829326ef631c
BLAKE2b-256 eb8f2de84fa1797190f85ffbd782d36a0d8b6affbc135f6754fab2b440cd1ad2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page