Skip to main content

A set that works with both hashable and non-hashable elements

Project description

All Purpose Set


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


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.10.tar.gz (178.2 kB view details)

Uploaded Source

Built Distribution

all_purpose_set-0.1.10-py3-none-any.whl (208.6 kB view details)

Uploaded Python 3

File details

Details for the file all_purpose_set-0.1.10.tar.gz.

File metadata

  • Download URL: all_purpose_set-0.1.10.tar.gz
  • Upload date:
  • Size: 178.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.15 CPython/3.7.1 Linux/5.1.2-arch1-1-ARCH

File hashes

Hashes for all_purpose_set-0.1.10.tar.gz
Algorithm Hash digest
SHA256 abc26982d71973a1cd27c20eb1e889e228fe26804a5deeffab00ff3cd9dfd6d2
MD5 83e6254fba7867872aa9549c8112679c
BLAKE2b-256 7104c14bf8be22f2febc64d34d2789aaad36f1c14012fc32d6059ddcb053a144

See more details on using hashes here.

File details

Details for the file all_purpose_set-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: all_purpose_set-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 208.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.15 CPython/3.7.1 Linux/5.1.2-arch1-1-ARCH

File hashes

Hashes for all_purpose_set-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 6ea32c0ca5937e22753b4f2d9ac7633fff47c605095f0ff58ae076fc5297cb09
MD5 ec9bd4eb47c66508eebb73ba0355cb8c
BLAKE2b-256 5ffa79ddcc203fe515cab78cc44b637257ca2a20d5e452129da453ae152225fb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page