A "sticky" wrapper for any object, that allow other objects to be add as propeties, which can be access through the .key notation or [key] notation. To unrap the object just add () notation to the end of the function.
Project description
Candy Wrapper
Candy Wrapper is a "sticky" wrapper for any object, which adds syntax surgar.
This wrapper wraps any object, and give the ability to add attributes to the object like a dictionary, much in the same way that pandas dataframs work.
Installation
You can install candy_wrapper with pip:
pip install candy_wrapper
Or with poetry:
poetry add candy_wrapper
Usage
from candy.candy_wrapper import Wrapper
foo = SomeClass()
# Wrap an object
candy = Wrapper(foo)
# Add an attribute to the object
foo['bar'] = 42
# Access the attribute
print(foo.bar) # prints 42
# You can also use setattr
setattr(foo,'hey',420)
# And getattr
print(foo['hey']) # prints 420
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
candy_wrapper-1.0.1.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for candy_wrapper-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6346d8986d123a9b5d86684eaaaf0e90b1ca35fd0af8bd134e9d2eb6bd2f142 |
|
MD5 | 7ff68983ef2d878af8c4bd415dbd6c2e |
|
BLAKE2b-256 | a209133d4f1b0898ad192f2bdcb162ecacdd3c215f36c11842d1c277ffc7bfdb |