What do you call a class not intended to be instantiated

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Mon Sep 22 14:14:53 CEST 2008


Tim Rowe a écrit :
> 2008/9/22 Bruno Desthuilliers <bruno.42.desthuilliers at websiteburo.invalid>:
>> Steven D'Aprano a écrit :
>>> On Mon, 22 Sep 2008 10:11:58 +0200, Bruno Desthuilliers wrote:
>>>
>>>> Steven D'Aprano a écrit :
>>>>> I have a class which is not intended to be instantiated. Instead of
>>>>> using the class to creating an instance and then operate on it, I use
>>>>> the class directly, with classmethods. Essentially, the class is used
>>>>> as a function that keeps state from one call to the next.
> 
> 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.




More information about the Python-list mailing list