Live data from Hacker News

DotDict: A simple Python library to make chained attributes possible

github.com

21–30 of 55 posts

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

#21

Earlier quoted context omitted.

I enjoy how much complete control Python enables. It’s fun to turn it into what resembles a different language. I want to make a library where you never ever call functions with fn() notation. But just utilize accessors and absolutely bastardize dicts.

My favorite example of this: https://old.reddit.com/r/learnprogramming/comments/kegalv/my...

This is horrifying and yet I can’t look away.

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

#22
post #5

This is more of a political statement than a proper library. More to demonstrate the flexibility of Python given I was able to so easily do this.

Could have been even easier: `argparse.Namespace` already has `__contains__()` ツ That said, https://pypi.org/project/addict/ has been around a long time...

That contains doesn’t permit the behavior, though. It would give you an AttributeError if you attempted this.

Yes, addict seems to be exactly what I was going for.

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

#25

In case anyone is looking for mature alternatives that are used in production https://pypi.org/project/python-box/ https://pypi.org/project/munch/

Neither of these appear to have the chained attribute feature, from my surface level parse.

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

#27

In case anyone is looking for mature alternatives that are used in production https://pypi.org/project/python-box/ https://pypi.org/project/munch/

Neither of these appear to have the chained attribute feature, from my surface level parse.

Box can do it with

https://github.com/cdgriffith/Box/wiki/Types-of-Boxes#defaul...

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

#28

Earlier quoted context omitted.

I enjoy how much complete control Python enables. It’s fun to turn it into what resembles a different language. I want to make a library where you never ever call functions with fn() notation. But just utilize accessors and absolutely bastardize dicts.

My favorite example of this: https://old.reddit.com/r/learnprogramming/comments/kegalv/my...

Wow, great job by this "beginner" just "learning a language"! Demonstrates knowledge of so many of Python intricacies that it's worth starting a Non-obfuscated Obfuscated Python Code Contest :)
Post reply on HN