[Python-Dev] Re: 2.2 features
Bob Ippolito
bob at redivi.com
Mon Jan 19 20:18:47 EST 2004
On Jan 19, 2004, at 6:36 PM, François Pinard wrote:
> [Guido van Rossum]
>> Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes:
>
>>> Now thow in 'isinstance' as an old way to spell a specific membership
>>> test (for types and classes) which doesn't have to be learned about
>>> at all.
>
>> I love it. 'x in type' as a shorthand for isinstance(x, type).
>> Checked into CVS!
>
> The above exchange is dated 2001-07-31, and I'm merely glancing over
> some old saved email. The above feature does not seem to be
> implemented
> in Python 2.3.2, as demonstrated by the script below. Has it been
> retracted? Not that I really need it, however! :-)
I don't know what happened to this before, but I'd give it a -1.. it
breaks some "fun" uses of metaclasses where you have a desire to use
__contains__. For example, I use an enumeration class as a container
for enumerators.. the enumeration metaclass implements __contains__,
__getitem__, and a few other things.
Anyways, why not:
mytype in type(foo).mro()
(and add support for old style classes, if you still use them)
-bob
More information about the Python-Dev
mailing list