callable classes

Duncan Smith buzzard at
Mon Dec 29 17:02:50 CET 2003

"Terry Reedy" <tjreedy at> wrote in message
news:_bydnV23friKY3CiRVn-gQ at
> "Duncan Smith" <buzzard at> wrote in message
> news:bskkig$sf6$1 at
> > > 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.
> >
> > Yes, I meant a class that defines a __call__ method.  Cheers.
> Which makes the *instances* callable, so you meant 'class with callable
> instances'.

Yes.  From what I can gather from reverse engineering other's code is that
the approach I am investigating is to create a single (global) callable
instance when the module is imported.  Something like,

pointwise_operation = pointwise_operation()

Then in the class where I originally had the pointwise methods I need
something like, e.g.,

def __mul__(self, other): return pointwise_operation.multiply(self, other)

I'm just not clear what the advantages / disadvantages are over just leaving
all the pointwise operation methods in the original class.  BTW it first
occurred to me to do this after reading Numeric's


More information about the Python-list mailing list