Live data from Hacker News

DotDict: A simple Python library to make chained attributes possible

github.com

1–10 of 55 posts

Re: DotDict: A simple Python library to make chained attributes possible

#7
Does it lazy-create leaf dicts on access? It would be preferable if they were only created on assignment, and failed if it’s just a get.

For example, if I call config.usors.adminn.naem I’d like it to fail loud and fast to point out the typos.

Re: DotDict: A simple Python library to make chained attributes possible

#8
post #6
post #3

This is the way. And that pip command is just clean.

Have I lost my marbles? It doesn't work? (temp5) ~/temp5 pip install . ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.

Run it from a clone of the repo to install it to the system / your user.

I don't see a name to install this from pypi (I see several dotdict libraries on there but they don't link here, so don't know if this is there somewhere).

Re: DotDict: A simple Python library to make chained attributes possible

#9

Does it lazy-create leaf dicts on access? It would be preferable if they were only created on assignment, and failed if it’s just a get. For example, if I call config.usors.adminn.naem I’d like it to fail loud and fast to point out the typos.

Code looks like it's on access, but I didn't test it.

Re: DotDict: A simple Python library to make chained attributes possible

#10

Does it lazy-create leaf dicts on access? It would be preferable if they were only created on assignment, and failed if it’s just a get. For example, if I call config.usors.adminn.naem I’d like it to fail loud and fast to point out the typos.

I don't think it's possible in Python to detect the difference between access or write (when it's nested attributes).
Post reply on HN