Paul Boddie wrote: > Kay Schluehr wrote: > > > > Spreading tiny function definitions all over the code > > may be finally not such a good idea compared with a few generic methods > > that get just called? OO might run out of fashion these days but Python > > is not Java and Pythons OO is pretty lightweight. > > I think you've successfully identified a recent trend in Python > development: the abandonment of fairly transparent object-oriented > techniques in favour of more opaque but supposedly more convenient > hybrid techniques. Unlike Java, Python's first class functions and > methods are already highly useful for callback-based systems - such > systems in Java suffer from interface proliferation and needless > one-off class definitions - but it seems to me that the subsequent > language evolution in favour of anonymous blocks brings fewer benefits > and can, as you say, diminish readability.
I was actually more concerned about extensibility than readability. Talking about classes being lightweight I mentioned classes to be "first-class" objects and intended constructions like this: class fetchPage_event(fetchPage('http://python.org')): def _showResponse(self, response) print "fancy formatting: %s" % response.text where all the registration and framework magics happens when the fetchPage_event class is created. Adding "callbacks" just happen when you add a method to the class. Here you have your "block" with no additional syntax. You can pass the fetchPage_event class around and add and overwrite methods in subclasses in the same fashion. A subclass can be created within any statement on the fly etc. Here you have an OO solution that is both short and has a clean design. -- http://mail.python.org/mailman/listinfo/python-list