On 03/07/2008, wesley chun <[EMAIL PROTECTED]> wrote:
>  on a related note, currently in Python, there is a callable() Boolean
>  function that returns True if the object's callable and False
>  otherwise. this will be removed for Python 3.x because you can just
>  use hasattr(obj, '__call__').

I believe this also comes down to a preference for EAFP over LBYL
(http://mail.python.org/pipermail/python-list/2003-May/205182.html).

i.e. instead of saying:

if callable(foo):
    foo()
else:
    # do something else

you can instead say:

try:
    foo()
except TypeError:
    # do something else

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to