[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: Need instruction on how to use isinstance
From:       Hans Mulder <hansmu () xs4all ! nl>
Date:       2010-06-30 23:39:49
Message-ID: 4c2bd5c9$0$22936$e4fe514c () news ! xs4all ! nl
[Download RAW message or body]

alex23 wrote:
> Stephen Hansen <me+list/pyt...@ixokai.io> wrote:
>> P.S. The removal of callable is something I don't understand in Python
>> 3: while generally speaking I do really believe and use duck typing, I
>> too have on occassion wanted to dispatch based on 'is callable? do x'.
>> Sometimes its not convenient to do so via duck typing. Its rare. But it
>> is there. That isinstance()/issubclass got a boost in power with the
>> ABC's and registering, while at the same time the ability to introspect
>> about the function-y callable-y ness of a function was removed? Makes no
>> sense to me. But alas!
> 
> There's always: isinstance(<object>, collections.Callable)

There's also: hasattr(<object>, '__call__').  It works in both 2.x and 3.x.


-- HansM
-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic