Most of the times, I am ending up using isinstance(A, list) or type(A) == list 
if I can. Therefore I feel like it’s not consistent. And isinstance itself has 
10 characters in its name already. Would love to follow == like syntax which we 
allow to compare types. 

I think I have to check how __eq__ is implemented for object before deciding if 
it’s really inconsistent or not. If the __eq__ is checking over object.__base__ 
or something similar, then my proposition makes sense. 

I am not in favor of adding an unnecessary operator writing for base class if 
it’s not the case. 

Excuse me if I am talking without really grasping the idea of using == for type 
comparison. I will do more research. 

> On 14. Jun 2019, at 21:05, Andrew Svetlov <andrew.svet...@gmail.com> wrote:
> 
> Bad idea.
> issubclass() works well.
> Adding operator support should be considered very carefully.
> I prefer a good portion of conservatism for such changes.
> How often the proposed change is needed?
> It adds a new complexity (documenting, teaching etc) without real
> benefits for daily jobs.
> 
>> On Fri, Jun 14, 2019 at 9:42 PM Joao S. O. Bueno <jsbu...@python.org.br> 
>> wrote:
>> 
>> And yet:
>> 
>> This is trivial to implement in a custom metaclass -
>> and maybe it would make default type too "noisy".
>> 
>> I am -1 on this going into normal classes,
>> and +0 for having a colaborative
>> metaclass with __lt__, __eq__ and such implementing
>> these on the stdlib. Maybe living in "types".
>> 
>> 
>> 
>> 
>> 
>>> On Fri, 14 Jun 2019 at 14:53, Brett Cannon <br...@python.org> wrote:
>>> 
>>> I think the logic breaks down with multiple inheritance. If you make C(A, 
>>> B), then you can say C > A and C > B, but then you can't say A > B or A < B 
>>> which breaks sorting.
>>> 
>>> If you want to know if a B inherits from Base, then I think `Base in 
>>> B.mro()` will cover that just as succinctly. And if you need to know 
>>> position you can compare indexes into the MRO.
>>> 
>>>> On Fri, Jun 14, 2019 at 1:06 AM eminbugrasaral--- via Python-ideas 
>>>> <python-ideas@python.org> wrote:
>>>> 
>>>> Let's assume you have this model:
>>>> 
>>>> ```
>>>> class Base:
>>>>    pass
>>>> 
>>>> class A(Base):
>>>>    pass
>>>> 
>>>> class B(Base):
>>>>    pass
>>>> 
>>>> class C(A):
>>>>   pass
>>>> ```
>>>> 
>>>> While we can do `A == B`, or `B == C` or `B == B`, I would expect to be 
>>>> able to compare like this as well: `A >= B (if B is subclass or itself of 
>>>> A)`, or `B <= C (if B is a subclass or itself of C)`
>>>> 
>>>> Because, since == means equality check. With the same logic, a class wraps 
>>>> another class is actually greater than this class from its type.
>>>> _______________________________________________
>>>> Python-ideas mailing list -- python-ideas@python.org
>>>> To unsubscribe send an email to python-ideas-le...@python.org
>>>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>>>> Message archived at 
>>>> https://mail.python.org/archives/list/python-ideas@python.org/message/6W7HCI4UIEAUD6AVLFSJF5Q2X55LWYZA/
>>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>> 
>>> _______________________________________________
>>> Python-ideas mailing list -- python-ideas@python.org
>>> To unsubscribe send an email to python-ideas-le...@python.org
>>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>>> Message archived at 
>>> https://mail.python.org/archives/list/python-ideas@python.org/message/IFW2UQNCCNYFZH3TFKD26WH7SKCP4YKT/
>>> Code of Conduct: http://python.org/psf/codeofconduct/
>> 
>> _______________________________________________
>> Python-ideas mailing list -- python-ideas@python.org
>> To unsubscribe send an email to python-ideas-le...@python.org
>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>> Message archived at 
>> https://mail.python.org/archives/list/python-ideas@python.org/message/UYNPZXZQQQQHNH7CW5M64ZFT2XKL2HPE/
>> Code of Conduct: http://python.org/psf/codeofconduct/
> 
> 
> 
> -- 
> Thanks,
> Andrew Svetlov
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/V5FGNQG2RNDMJ26ZJAXVSKKIJEWDIFX4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to