[Python-3000] callable()

Andrew Koenig ark at acm.org
Tue Jul 18 20:28:49 CEST 2006


> Then it becomes a matter of whether it's worth having callable()
> around as an alternative spelling. Those arguing in favour of
> it would have to explain whether we should also have addable(),
> subtractable(), mutiplyable(), indexable(), etc. etc. etc...

I'd love to be able to determine whether a+b can be evaluated, and, if so,
what function it would call.  I don't think such a determination fits neatly
into a notion that could be spelled "addable".  Note that when you evaluate
a+b, it might call a.__add__ or b.__radd__, or perhaps even something else
entirely in the future.  So it might be nice to have a function to which you
can give two values and a binary operator (or one value and a unary
operator), and which would tell you what function, if any, that operator
would call.

You might even treat "()" as an operator and unify it with the rest of them.
Just one more form of introspection.

But I don't think a separate function for each operator would be the best
way of achieving that introspection.





More information about the Python-3000 mailing list