KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
attridict
★ 11
Open GitHub ↗
Python attribute dictionary
Download README (.md)
Explore Similar Repositories
LeagueSumTimer
:
In-game overlay Flash timer for popular game League of Legends.
BankData
:
List of IBAN, BIC and Clearing numbers from bankinfrastruktur.se
micro-react
:
A micro React that implements React core concepts.
hikivision-sdk
:
hikivision sdk 封装
One-day
:
One day plugin for Minecraft
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
attridict
?
Download (.md)
# attridict   A Python package implementing atrribute dictionary. This provides an easier and cleaner way to access dict values using their keys as attributes. It is typically a dict child, maintaining all the dict functionalities, but including some extra features. ## Installation To install the package from PyPI, use: ``` pip install attridict ``` ## Usage Creating an attridict object ```python >>> import attridict >>> att = attridict() >>> att {} >>> att.foo = "bar" >>> att.foo 'bar' >>> att {'foo': 'bar'} ``` <br/> A dict can be converted into an attridict object by passing it as an argument ```python >>> import attridict >>> data = {'red': 'hot', 'blue': 'cold'} >>> colors = attridict(data) >>> colors {'red': 'hot', 'blue': 'cold'} >>> colors.red 'hot' ``` <br/> Modifying attridict object ```python >>> import attridict >>> data = {'red': 'hot', 'blue': 'cold'} >>> colors = attridict(data) >>> colors {'red': 'hot', 'blue': 'cold'} >>> colors.blue 'cold' >>> colors.blue = "sky" >>> colors.red = "rose" >>> colors.blue 'sky' >>> colors.red 'rose' >>> colors {'red': 'rose', 'blue': 'sky'} >>> colors.green = "grass" >>> colors {'red': 'rose', 'blue': 'sky', 'green': 'grass'} ``` <br/> Typical `dict` operations work on attridict objects ```python >>> import attridict >>> data = {'red': 'rose', 'blue': 'sky'} >>> colors = attridict(data) >>> colors {'red': 'rose', 'blue': 'sky'} >>> colors.red 'rose' >>> colors["red"] 'rose' >>> colors["red"] = "tomato" >>> colors["red"] 'tomato' >>> colors.red 'tomato' ``` <br/> Nested attribute access ```python >>> import attridict >>> data = {'foo': {}} >>> att = attridict(data) >>> att {'foo': {}} >>> att.foo.bar = 'baz' >>> att.foo.bar 'baz' >>> att {'foo': {'bar': 'baz'}} ``` <br/> YAML serializable ```python >>> import attridict >>> import yaml >>> data = {'foo': {'bar': 'baz'}} >>> att = attridict(data) >>> yaml.dump(att) '!attridict\nfoo:\n bar: baz\n' >>> yaml.safe_dump(att) 'foo:\n bar: baz\n' ``` ## License The project is MIT licensed