Python becoming less Lisp-like

Kent Johnson kent37 at tds.net
Wed Mar 16 01:54:56 CET 2005


Steven Bethard wrote:
> Bruno Desthuilliers wrote:
> 
>>> class CommandMenuSelectionCallback:
>>>     def __init__(self, key):
>>>         self.key = key
>>>
>>>     def __call__(self):
>>>         print self.key
>>
>> Looks like Java.
> 
> 
> When was the last time you used Java?  It has no support for using 
> classes as callable objects.  __call__ would have to be invoked 
> manually; you definitely couldn't have a CommandMenuSelectionCallback 
> instance masquerading as a function as this code (basically) does.

It's like Java in that it uses a short helper class to define an event callback. In the case of Java 
it would be an anonymous inner class programming to an interface. It's like Java in that it uses 
five lines of code to do what Python can do in one.

Do you really prefer this verbosity to a lambda expression? Yikes!

Kent



More information about the Python-list mailing list