Python abstract data structure (ADT) extension
Project description
adt-extension
Python abstract data structure (ADT) extension.
Install:
pip install adt-extension
Import:
from adt_extension import SwitchDict
Extensions
Currently the package have the ADT extensions:
Class | Extension of | Description |
---|---|---|
SwitchDict |
dict |
Dictionary with the possibility of behavior of a switch case . |
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
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for adt_extension-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29dbc5296faec0799b9e2d6805d8ff0b5a123eeacb86e904f0b6613c6f304139 |
|
MD5 | 59deb8ccbc52ac0c77604cd6f206fdc8 |
|
BLAKE2b-256 | e3070e4539d2f4dab158c1cdadcbb39cfdd646a83d6898bfb85369d01b36b4da |