adt-extension
Python abstract data structure (ADT) extension.
Install:
pip install adt-extension
Import:
from adt_extension import Set, SwitchDict
Extensions
Currently the package have the ADT extensions:
| Class | Extension of | Description |
|---|---|---|
Set |
set |
Set with element type and validation rule. |
SwitchDict |
dict |
Dictionary with the possibility of behavior of a switch case. |
Set
Set with element type and validation rule for the elements that will be inserted into the set.
Example:
from adt_extension import Set
# A set with only even integers
set_int_even = Set(element_type=int, rule=lambda x: (x % 2 == 0))
# Elements that satisfies the element type and validation rule
set_int_even.update({4, 6})
# Elements that satisfies the element type, but not validation rule
set_int_even.update({5})
# Elements that not satisfies the element type
set_int_even.update({"qwe", True})
print(set_int_even)
# Output:
# Set({4, 6})
# Remove element type
set_int_even.element_type = None
# Remove validation rule
set_int_even.rule = None
SwitchDict
Dictionary with the possibility to perform a function or return a value when trying to access a nonexistent index in the dictionary class.
Example:
from adt_extension import SwitchDict
# Same behavior of a normal dictionary
switch_dict = SwitchDict({
'Apartament': 125,
'House': 250,
'Condominium': 300,
})
# Add default case
switch_dict.default_case = 999
# List example
properties_list = [
'Apartament',
'House',
'Condominium',
'Treehouse',
'Hotel',
]
# Get values
properties_values = [ switch_dict[ x ] for x in properties_list ]
print(properties_values)
# Output:
# [ 125, 250, 300, 999, 999 ]
# Remove default case, becomes a normal dictionary
switch_dict.default_case = None
Metadata
Release files for adt-extension 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adt_extension-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for adt_extension-0.2.0-py3-none-any.whl |
Release files / adt_extension-0.2.0-py3-none-any.whl
| Download URL | adt_extension-0.2.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7434dc27223a4450f82092048a13d36d6e8a08102a04cd675b58bd5c48e96d1
|
|
BLAKE2b-256 checksum How to use checksums |
71939660444043d6824949902b14574295b66c4a8737a2c7b6e7f24c63630fb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for adt-extension 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.