Roy Smith wrote:
On May 12, 2:29 pm, Ethan Furman <et...@stoneleaf.us> wrote:
While it is wrong (it should have 'built-in' precede the word 'types'),
it is not wrong in the way you think -- a subclass *is* a type of its
superclass.
Well, consider this:
class List_A(list):
"A list subclass"
class List_B(list):
"Another list subclass"
a = List_A()
b = List_B()
print a == b
It prints "True". Neither a nor b are a type of the other:
print isinstance(List_A, List_B)
print isinstance(List_B, List_A)
False
False
Okay, considering:
List_A is a user-defined type.
List_B is a user-defined type.
Both are sub-classes of list.
Corrected documentation (which says 'built-in types' etc, etc) says
nothing about user-defined types not being able to be equal to each other
neither List_A nor List_B have overridden the __eq__ method, so
list.__eq__ will be used...
conclusion:
if they have equal elements in the same order, they will compare
equal since they are, in fact, list's
Do you not get the same conclusion?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list