?
=?ISO-8859-1?Q?Sch=FCle_Daniel?=
Hello,
first question
In [117]: cmp("ABC",['A','B','C'])
Out[117]: 1
against what part of the list is the string "ABC" compared?
second question
In [119]: class X(object):
.....: pass
.....:
In [120]: X() < X()
Out[120]: True
In [121]: X() < X()
Out[121]: False
In [122]: X() < X()
Out[122]: True
In [123]: X() < X()
Out[123]: True
In [124]: X() < X()
Out[124]: False
class X does not implement < and cmp
what is this comparision is based on?
third question
sort([[1,2,3],["ABC"],['Z','A'], X(), 4)
how does python handle heterogenous items in the list
in this case?
first I assumed that cmp function used in sort
is based on len, when the items are sequences, but this is wrong
Regards, Daniel
first question
In [117]: cmp("ABC",['A','B','C'])
Out[117]: 1
against what part of the list is the string "ABC" compared?
second question
In [119]: class X(object):
.....: pass
.....:
In [120]: X() < X()
Out[120]: True
In [121]: X() < X()
Out[121]: False
In [122]: X() < X()
Out[122]: True
In [123]: X() < X()
Out[123]: True
In [124]: X() < X()
Out[124]: False
class X does not implement < and cmp
what is this comparision is based on?
third question
sort([[1,2,3],["ABC"],['Z','A'], X(), 4)
how does python handle heterogenous items in the list
in this case?
first I assumed that cmp function used in sort
is based on len, when the items are sequences, but this is wrong
Regards, Daniel