A Set implementation that tracks added and removed elements.
Project description
A Set implementation that tracks added and removed elements.
Usage
>>> from history_set import HistorySet
>>> history_set = HistorySet([1, 2, 3])
>>> history_set.add(4)
>>> history_set # Prints: {1, 2, 3, 4}
>>> history_set.added() # Prints: {4}
>>> history_set.remove(1)
>>> history_set # Prints: {2, 3, 4}
>>> history_set.removed() # Prints: {1}
Special case
By default, if an element is added and later removed, it will not be tracked in history
>>> history_set = HistorySet([1, 2, 3])
>>> history_set.add(4)
>>> history_set.remove(4)
>>> history_set.added() # Prints: set()
>>> history_set.removed() # Prints: set()
If you require these elements to be tracked, you can construct the object with the eidetic keyword argument
>>> history_set = HistorySet([1, 2, 3], eidetic=True)
>>> history_set.add(4)
>>> history_set.remove(4)
>>> history_set.added() # Prints: {4}
>>> history_set.removed() # Prints: {4}
Test
You can run the tests using tox
tox
Publish
To publish a new version of this package your Pypi user needt to be added to the project. (Ask Tjaart to give you access)
# Update version number in setup.py
python setup.py sdist
twine upload dist/*
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
history-set-0.1.1.tar.gz
(2.1 kB
view details)
File details
Details for the file history-set-0.1.1.tar.gz
.
File metadata
- Download URL: history-set-0.1.1.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c28c2eedfcb0551aed611a4ecb0fb7846f49ef85a8df393e12da2cdca474c3 |
|
MD5 | 58aadc6d49685a53073aaa3a71ac42f8 |
|
BLAKE2b-256 | 3d53aa5748cfa7f153bf4fbc1d78a50aa26586fe8f18fc419ec141bebe58961b |