A set that works with both hashable and non-hashable elements
Project description
All Purpose Set
Note: This document is best viewed on github. Pypi's headers are all caps which presents inaccurate information
Table of Contents
What is it?
- A set which doesn't require hashable contents
Why create it?
-
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 }
Simple usage
from all_purpose_set import ApSet
someDict = { "key": "value" }
someSet = ApSet([someDict])
print(someDict in someSet) # prints True
See also
Api
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.
class ApSet([a list])
- all methods return
self
unless specified otherwise - iterates in the order of insertion
- currently the internal methods implemented are
- __contains__
- __iter__
- __len__
add(something)
clear()
has(something) => bool
- a function alternative to
key in aSet
remove(something)
- raises a
KeyError
if the element doesn't exist
Test
#
# you must have poetry installed
#
$ poetry shell
$ poetry install
$ python runTests.py
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
all_purpose_set-0.1.6.tar.gz
(178.2 kB
view hashes)
Built Distribution
Close
Hashes for all_purpose_set-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7b15f1b972ef15df6a64b0bc2ba3a19bc9a3f3ef5a9999aaabdcad25c3b5c8a |
|
MD5 | 021718c6c86683111580e6ddd8536ebc |
|
BLAKE2b-256 | 33cd7fa5f8e4b1b16e9c7e08325361f7e193fbf6a01c5cd1dcea8f7e1a5905ff |