callable classes

anton muhin antonmuhin at rambler.ru
Fri Dec 26 13:53:15 EST 2003


Duncan Smith wrote:
> I recently started to rewrite a class and decided to take a bunch of related
> methods and put them in a separate callable class.  (They're all what I
> would call pointwise operations on pairs of instances, they raise exceptions
> for identical reasons, and they all return a new instance).  It seemed like
> a good idea at the time, but now I'm not so sure.  So my very general
> questions are:
> 
> Is this a reasonable use for a callable class?
> 
> In what circumstances are callable classes particularly useful?  (Maybe I
> haven't racked my brains long enough.)
> 
> Cheers.  TIA.
> 
> Duncan
> 

What do you mean by 'callable class'? Classes are callables. Ot you mean 
  a class that defines __call__ method? In this case it's really useful.

regards,
anton.




More information about the Python-list mailing list