
[Guido van Rossum]
Marcin 'Qrczak' Kowalczyk <qrczak@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! :-) Python 2.3.2 (#1, Nov 9 2003, 20:14:22) [GCC 3.3 20030226 (prerelease) (SuSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. from __future__ import nested_scopes, generators, division del __future__, fcntl, termios, joined, character, nested_scopes, generators, division sys.ps1 = '>>> ' from __future__ import nested_scopes, generators, division del __future__, fcntl, termios, joined, character, nested_scopes, generators, division sys.ps1 = '>>> '
0 in int Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: iterable argument required isinstance(0, int) True int <type 'int'>
-- François Pinard http://www.iro.umontreal.ca/~pinard

[Guido van Rossum]
Marcin 'Qrczak' Kowalczyk <qrczak@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! :-)
Yes, it was retracted. From the CVS log the next day: ---------------------------- revision 2.16.8.73 date: 2001/08/01 03:56:39; author: gvanrossum; state: Exp; lines: +1 -21 Rip out again the 'x in type' support. Further newsgroup discussion showed it was confusing. E.g. people tried "if x in [int, long]: ...". ---------------------------- In retrospect I think it was too cute... --Guido van Rossum (home page: http://www.python.org/~guido/)

On Jan 19, 2004, at 6:36 PM, François Pinard wrote:
[Guido van Rossum]
Marcin 'Qrczak' Kowalczyk <qrczak@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
participants (3)
-
Bob Ippolito
-
François Pinard
-
Guido van Rossum