[SciPy-dev] Documenting function-like classes
Sun Oct 25 20:58:50 CDT 2009
On Sun, Oct 25, 2009 at 20:57, David Goldsmith <firstname.lastname@example.org> wrote:
> And a follow up...
> On Sun, Oct 25, 2009 at 6:42 PM, Anne Archibald <email@example.com>
>> Generally, I use one when an object I am representing with a class has
>> a natural evaluation map. So, for example, an object representing a
>> polynomial ought to be a class - you can multiply it, you can compute
>> derivatives and antiderivatives, you can look at its coefficients -
>> but you should also be able to use it like a function, to evaluate at
>> a particular place.
> However, since the syntax myClass() is already "spoken for" by the c-tor,
> for the function-like behavior don't you still have to: A) define a method
> attribute, and B) call it using '.' resolution syntax?
No. You call the instance that is created by the constructor, not the class.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Scipy-dev