Re:Dear Python
by viraptor on Tuesday February 02, 2010 @05:12PM
(#1096324)
I see the problem when using third-party libraries, but if I was designing my own... Objects are pretty cheap in python:
only one line of overhead (class line). And I'm pretty sure you can hack __dict__ in init, or use metaclasses so that the events are chained automatically, even without calling `Button.onClick(self)`. You can construct / add the object to it's container the same way (Somebutton(), instead of Button())
[ Parent
| on HN ]
Should you have to hack __dict__ in init to get functionality that would be more easily/clearly expressed using an anonymous function?
Not trying to defend python's decision here but I have honestly yet to see an example where anonymous function really led to better code.
In my experience (mostly JS and AS) they rather usually lead to little pieces of logic scattered all over the place and insufficient decoupling.