How can I check how standard classes (e.g. socket) implement their rich comparisons (e.g. __eq__
) in Python3?
I'm learning Python and have implemented a web server in the language.
I'm not sure whether it's safe to compare sockets by ==
to determine if the listening server socket s
is part of the read list returned by select.select()
.
I've consulted the documentation for sockets (see below), but a search for "equal" doesn't show anything.
Is there a general rule that rich comparisons are left unimplemented unless otherwise stated? If so, how is comparison performed?
References:
https://docs.python.org/2/reference/datamodel.html#object.cmp https://docs.python.org/3/library/socket.html