Connecting Tech Pros Worldwide Help | Site Map

Re: ABCs -> infix syntax for isinstance() ?

Boris Borcic
Guest
 
Posts: n/a
#1: Oct 9 '08
Terry Reedy wrote:
Quote:
Boris Borcic wrote:
....
Quote:
Quote:
>>
>- allowing containment tests, ie "x in Number" to invoke isinstance()
>in the background when the container is of type <type>. My brain is
>too muddled by flu at the moment, to see whether Guido's fabled time
>machine allowed him to already provide all the necessities in py26.
>Any takers ?
>
I believe this could be done by adding a __contains__ method to type.
(It does not have one now). Then x in X should work for all classes
that are instances of type or a subclass thereof.
Can this be done short of patching the source and recompiling (eg, with ctypes
perhaps) ?

Cheers, BB

Closed Thread