3 ms·
If you're in Python, and are afraid of "anemic" objects, I would recommend checking out collections.namedtuple. It's a fantastic lightweight and performant obje
by falcolas 10y ago
If you're in Python, and are afraid of "anemic" objects, I would recommend checking out collections.namedtuple. It's a fantastic lightweight and performant object-like data structure.
You also get a few additional features, such as in-order iteration, the parameters are fixed at run time, and there's a method for turning it into an ordered dictionary (which is serializable in, wait for it, JSON).
- ajdlinux 10y agoIf you're not limited to the standard library, https://github.com/hynek/attrs https://github.com/hynek/attrs is also worth taking a look at.
- StavrosK 10y agoI just found out about it in this article, and already posted a new story (it looks that good): https://news.ycombinator.com/item?id=12359522 https://news.ycombinator.com/item?id=12359522