Greg Ewing wrote:

> For that purpose, hasattr(obj, '__call__') is sufficient,
> I think. And if it's not, the API you're trying to
> implement is ill-conceived in the first place, just like
> testing for sequenceness is not a well-defined operation.

I should add that for ipython's purposes, it seems I could just implement

def callable(o): return hasattr(o,'__call__')

and it would be OK.  I hadn't realized that Python reports true to the
hasattr() call form for lambdas, simple plain functions, functions in
extension modules, extension types, and most things I could quickly think
of and check from code I have.  I wasn't aware of this fact, I thought it
would only be true for instances of classes which explicitly implemented a
__call__ method, and that callable() did some other magic.

Having understood this, I then don't really care whether callable() goes
away or not, it's a one-liner as an interactive ipython convenience.  Sorry
for not checking more carefully, I trusted a misconception I had.

Cheers,

f

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to