2008/9/22 Bruno Desthuilliers <[EMAIL PROTECTED]>:

>> Sounds to me like a functor, aka a function object:
>> http://en.wikipedia.org/wiki/Function_object
>>
>
> Ok, then the simple solution is to implement a callable type (__call__
> method), possibly with appropriate support for the descriptor protocol if
> it's meant to be usable as a method.

Yes -- and instantiate the thing and keep the state in the instance,
rather than keeping the state in the class, so that it's possible to
safely have more than one of them if a later design change calls for
it (probably what led people off onto the sidetrack of thinking a
singleton was called for).  That's the classic way of implementing a
"class [to be] used as a function".

-- 
Tim Rowe
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to