Re:DotDict: A simple Python library to make chained attribut...
by heisenzombie on Wednesday August 02, 2023 @06:09PM
(#36978431)
Yeah it does. If you do:
x = dd()
print(x.tyypo.a.b)
you'll get "DotDict()"
The problem is that an object can't know whether you're getting a node that you're later going to assign a leaf to... or whether you're getting the node because you want to get the node.
x = dd()
x.a.b.c = "Foo"
is equivalent to:
x = dd()
y = x.a.b
y.c = "Foo"
So "x.a.b" can't raise an exception.
Now, it's python, so you can do unholy things to make pretty much anything work. But I think it would be ugly.
The problem is that an object can't know whether you're getting a node that you're later going to assign a leaf to... or whether you're getting the node because you want to get the node.
is equivalent to: So "x.a.b" can't raise an exception.Now, it's python, so you can do unholy things to make pretty much anything work. But I think it would be ugly.