Bruno Desthuilliers dixit : > Boris Borcic a écrit : > > > Given the ABC innovation, maybe an infix syntax for isinstance() would > > be good. > > > Possibilities : > > > - stealing "is" away from object identity. As a motivation, true use > > cases for testing object identity are rare; > > "x is None" is a *very* common test. Using a _marker object as default > arg value when you want to accept None as a meaningfull value is pretty > common.
(a) Okay, 3to2 can take care of "x is NoneType" and/or "x == None". The latter could also be a compiler optimization. (b) Give me None==False and in exchange I will adopt "x is None" as sacred forever :) (not quite BTW, how much future do you think is there in turning 2to3 into some usable 3to2 ? What about "NtoM" as a more generic Python project ?) > Testing a class identity often happens when writing metaclasses This kind-of-talks for Terry's proposition : adding a __contains__ to type, looks like easier to pass before lead metaclass-writers. Or if not easier to pass, easier to write a simple patch for. So "x in Number" syntax. A intriguing wider proposition would be to transpose Ruby's notion of "Open Classes" to Python built-in metaclasses (or just to type itself ?). Let's threaten lead metaclass-writers with *that* if they don't settle on just type.__contains__ = lambda cls,i : isinstance(i,cls) !! :) Cheers, BB -- http://mail.python.org/mailman/listinfo/python-list