Skip to main content

Probed collections

This project is part of the Pyrustic Open Ecosystem.

Installation . Latest . Documentation

Overview

Sometimes you need to know when the content of a data collection has changed.

Probed is a library that exposes three classes: ProbedDict, ProbedList and ProbedSet.

These classes are containers like the built-in Python containers (dict, list, set) which they subclass but with not a twist but two twists:

  • be notified when the content of your data collection changes (if you wish to be notified);
  • being able to put a probe into data collection to do more than just be notified.

Let's write a script to see Probed in action:

# script.py
from probed import ProbedList


def on_change(context):
    msg = "\nThe {} operation changed the {} collection\n{}"
    print(msg.format(context.operation, context.container, context.collection))


plist = ProbedList(on_change=on_change)
plist.append("hi")
plist.insert(1, "friend")

Let's run the script:

$ python3 script.py

The append operation changed the list collection
['hi']

The insert operation changed the list collection
['hi', 'friend']

Now, let's discover what the probe feature does and how to use it:

# script.py
from probed import ProbedSet


def probe(context):
    # this probe will lower strings added to the collection
    # also, the object None isn't allowed in the collection
    if context.operation == "add":
        if context.item is None:
            context = None
        else:
            context.item = context.item.lower()
    return context


pset = ProbedSet(probe=probe)
# add items
pset.add("RED")
pset.add(None)
pset.add("Green")
# print
print(pset)  # {'red', 'green'}

In the last script, the probe was used to control the items added to the data collection.

All operations that change the contents of the built-in containers are covered by probed.

Read the modules documentation !

Related project

The Shared data exchange and persistence library uses Probed to implement the autosave feature !

Discover Shared !

Installation

Probed is cross platform and versions under 1.0.0 will be considered Beta at best. It is built on Ubuntu with Python 3.8 and should work on Python 3.5 or newer.

For the first time

$ pip install probed

Upgrade

$ pip install probed --upgrade --upgrade-strategy eager



Back to top

Release files for probed 0.0.11

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

Source distribution (sdist)

Source distribution for probed 0.0.11
File Size Uploaded
probed-0.0.11.tar.gz 7.7 kB Details

Built distribution (wheel)

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

Total release size: 22.9 kB

Release files / probed-0.0.11.tar.gz

Download URL probed-0.0.11.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2da4cc175a4d6d7b1baa9fcb313f4d4d61d861f36bd52bb5e4007e517070033c
BLAKE2b-256 checksum
How to use checksums
93d744f901075cfbf3c2b637d8a6d3931281716f39f38b603e1455231a02d348
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.6.1 requests/2.9.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.5.2

Release files / probed-0.0.11-py3-none-any.whl

Download URL probed-0.0.11-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3bb3c6d9da3712cbffca56340ed637a01619fa53d74887f90b39ada5a36d16c9
BLAKE2b-256 checksum
How to use checksums
60df9cea354033f125bc63147180afb8a1f7ea66762d49ff4c87f572a3bee65f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.6.1 requests/2.9.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.5.2

Release history Release notifications | RSS feed

This release

0.0.11 This release

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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