ABCs -> infix syntax for isinstance() ?

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Mon Oct 6 12:28:24 EDT 2008


bborcic at gmail.com a écrit :
> 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

Why so ?

> 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,

I said "type identity testing", not isinstance() or issubclass() testing.

(snip)

> A intriguing wider proposition would be to transpose Ruby's notion of
> "Open Classes" to Python built-in metaclasses (or just to type
> itself ?).

No, thanks. Even the Ruby guys start to think making evrything open may 
not be such a good idea after all.

And anyway, I don't see how any of the above address the point that your 
premise that "true identity testing is rare" is just wrong...




More information about the Python-list mailing list