NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #1597 most downloaded on PyPI
Addict is a dictionary whose items can be set using both attribute and item syntax.
Last release 6 years ago
no release in 18 months
Release timing varies
gaps range from 2 months to 1.4 years
Some releases are documented
notes for 10 of 31 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
31 releases · first in 2014
Calling .freeze() forbids getting/setting missing keys. Use .unfreeze() to undo. Ref #121, #130. Thanks to @sumukhbarve.
Calling .freeze() forbids getting/setting missing keys. Use .unfreeze() to undo. Ref #121, #130. Thanks to @sumukhbarve.
Releasing with changes from 8181a94517398f123187118e4765baaf65e6bafb. On PyPi.
Releasing with changes from 8181a94517398f123187118e4765baaf65e6bafb. On PyPi.
Fixes https://github.com/mewwts/addict/issues/112
One column per quarter.
Fixes https://github.com/mewwts/addict/issues/112
In this release it's easier / better to inherit from a Dict instance. Thanks to @MisterVladimir for contributing.
In this release it's easier / better to inherit from a Dict instance. Thanks to @MisterVladimir for contributing.
This release ensures the LICENSE file is included for easier packaging in Linux distros.
This release ensures the LICENSE file is included for easier packaging in Linux distros.
You can now deep copy an addict instance by doing ad.deepcopy()
You can now deep copy an addict instance by doing ad.deepcopy()
Nothing published for this version
addict now has setdefault which should properly work.
addict now has setdefault which should properly work.
Thanks to @bmerry.
This fixes several issues with addict, namely #85, #86 and #88.
This fixes several issues with addict, namely #85, #86 and #88.
Thanks to @bmerry for spotting these faults in addict.
addict now no longer adds keys when you peek on items! ☄️
addict now no longer adds keys when you peek on items! ☄️
This means that it's functionality now differs from defaultdict, where calls to getitem will produce a new entry in the defaultdict. Hence, the following now happens when you peek on an empty key:
from addict import Dict
>>> a = Dict()
>>> a.a
{}
>>> a
{}
However, calls to setitem works just like before:
>>> a.a = 2
>>> a
{'a': 2}
This is possible because of a new implementation detail. Calls to getitem now still returns a new addict Dict, but this instance have to special keyword arguments __parent and __key supplied to __init__. The __parent argument is meant to hold a reference to the Dict in which we called getitem, and the __key argument refers to the key we were peeking on. When, or rather if, this new Dict instance's setitem method is called, it will also call setitem on it's __parent with the key __key and the value itself. Let me illustrate with an example.
>>> a = Dict()
>>> b = a.b
>>> a
{}
>>> b
{}
Above, both a and b are empty Dicts. But let's see what happens to a when we set an item on b
>>> b.c = 2
>>> b
{'c': 2}
>>> a
{'b': {'c': 2}}
Magic.
You should consider these arguments to __init__ reserved, they will not appear as keys in your Dict, and will cause trouble if used in the wrong way. Example:
>>> a = Dict(__parent=2, __key='a')
>>> a.v = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mats/dev/mewwts/addict/addict/addict.py", line 28, in __setattr__
self[name] = value
File "/Users/mats/dev/mewwts/addict/addict/addict.py", line 39, in __setitem__
p.__setattr__(key, self)
AttributeError: 'int' object has no attribute 'a'
Nothing published for this version
New, potentially _breaking_, feature is that we do not modify or clone objects set after construction, as we did before. The following will throw Attr
Version 1.0.0
New, potentially breaking, feature is that we do not modify or clone objects set after construction, as we did before. The following will throw AttributeError
a = Dict()
a.a = {}
a.a.b = 2 # throws AttributeError as a.a is a dict (and not an addict)
For this functionality you should rather do
a = Dict()
a.a = Dict()
a.a.b = 2 # works
Items set through the constructor will be cloned (as before)
a = Dict({'a': {'b': 2}})
a.a.c = 3 # works
Mats
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →