Python class decorator that adds selection chaining
Project description
ChainGang: python class decorator that adds selection chaining
What is it?
ChainGang is a Python package that provides a class decorator function that adds selection chaining to classes with nested items.
Where to get it
The source code is currently hosted on GitHub at: https://github.com/eddiethedean/chaingang
# PyPI
pip install chaingang
Example
from chaingang import selection_chaining
# decorate a class with nested items
@selection_chaining
class ChainList(list):
...
cl = ChainList([[1, 2, 3], [4, 5, 6]])
# select inner item with comma separated indexes
cl[1, 2] -> 6
# same as bracket chaining
cl[1][2] -> 6
# set inner item value
cl[1, 2] = 100
cl -> [[1, 2, 3], [4, 5, 100]]
# delete inner item
del cl[1, 1]
cl -> [[1, 2, 3], [4, 100]]
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
chaingang-0.0.1.tar.gz
(2.2 kB
view hashes)
Built Distribution
Close
Hashes for chaingang-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5602532f5b2d94bab7171bac964f5590cf44a4ad5ce0051f21cecfc5205019b4 |
|
MD5 | 553ad65414254193a6fb23c6119f76bb |
|
BLAKE2b-256 | 79ba05f8cce6f039fe587ecdf526ef135e49e08eea21bb86486eccde0828d74a |