Tiny observer for the attributes of Python objects.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file objerve-0.2.0.tar.gz.
File metadata
- Download URL: objerve-0.2.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b888fba69b7fb553e82fbfb07e9cc0946d3cea122076dbc8248772f62e96fbae
|
|
| MD5 |
60d127f898796a1ad43fc3cd9bd9aac4
|
|
| BLAKE2b-256 |
915bcdce32fff36c8b78c06f16bcb9c962246863a10abc9d15dc49518c79e1eb
|
File details
Details for the file objerve-0.2.0-py3-none-any.whl.
File metadata
- Download URL: objerve-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18eae315200fa2b9e80b2c8ce9bfe37718e93d9eb59143ff696b378e32f1c589
|
|
| MD5 |
a0115dbdb32fe425d9b5b88120d58293
|
|
| BLAKE2b-256 |
918d2dcb82571f66e0b3d64516375f96cf7e313d7cde60b3cefdaa1b6305d0f4
|