Hafersack
Hafersack is a really small library to store and retrieve metadata in any object. Hafersack can store anything and uses strings as keys.
Installation
$ pip install hafersack # or use your preferred package manager
How to use
Creating a singleton Hafersack instance is recommended, but not required. As long as you use the same key, you can access the same metadata from different Hafersack instances.
from hafersack import Hafersack
sack = Hafersack()
class MyClass:
pass
obj = MyClass()
sack.set(obj, "key1", "value1")
sack.set(obj, "key2", 42)
assert sack.has(obj, "key1")
assert sack.has(obj, "key2")
assert not sack.has(obj, "key3")
assert sack.get(obj, "key1") == "value1"
assert sack.get(obj, "key2") == 42
sack.delete(obj, "key1")
assert not sack.has(obj, "key1")
assert sack.has(obj, "key2")
Metadata
Release files for hafersack 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hafersack-0.1.0.tar.gz | 1.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hafersack-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.7 kB
Release files / hafersack-0.1.0.tar.gz
| Download URL | hafersack-0.1.0.tar.gz |
|---|---|
| Size | 1.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e79ef3922681312dec39ccbb2d3f9069b5e36c6f2e596ceedacf0fb1e3822991
|
|
BLAKE2b-256 checksum How to use checksums |
0e68812dc3da9569a1997834789a239aa8dd12f2e352b784889cdc1a9b55cbef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.23 {"installer":{"name":"uv","version":"0.9.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hafersack-0.1.0-py3-none-any.whl
| Download URL | hafersack-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8003d5eb674eb214e296ea82999cc647cae464ab1f3772a27eb0def750d1d606
|
|
BLAKE2b-256 checksum How to use checksums |
88a19bc3344e7e1e42924c40bd8074cf60a28205d1158dda693d23918f7c25df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.23 {"installer":{"name":"uv","version":"0.9.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|