Table of Contents
- A set which doesn't require hashable contents
-
I often have a need to store non-hashable contents in a set. For example storing a dict isn't possible with the builtin set.
# doesn't work someDict = { "key": "value" } someSet = { someDict }
from all_purpose_set import ApSet
someDict = { "key": "value" }
someSet = ApSet([someDict])
print(someDict in someSet) # prints True
Note: This api is young and subject to change quite a bit. There also may be functionality present in the builtin set which this set doesn't cover. I'm willing to add it so please just raise a github issue or PR with details.
- all methods return
self
unless specified otherwise - iterates in the order of insertion
- currently the internal methods implemented are
- __contains__
- __iter__
- __len__
- a function alternative to
key in aSet
- raises a
KeyError
if the element doesn't exist
#
# you must have poetry installed
#
$ poetry shell
$ poetry install
$ python runTests.py