how to get the ordinal number in list

Robin Becker robin at reportlab.com
Mon Aug 11 10:32:47 EDT 2014


On 11/08/2014 13:30, alister wrote:
> It already is a different operator from equality which is ==
>
> perhaps it would have been better if the behaviour of these two operators
> were reversed (= for equality & == for assignment) but i suspect that
> Idea if even considered was quickly discarded as it would cause major
> confusion to programmers who work with multiple languages


Of course Python can be even more confusing so that for example

 >>> class NeverEqual(int):
... 	def __new__(cls,v):
... 		self = int.__new__(cls,v)
... 		return self
... 	def __eq__(self,other):
... 		return False
...
 >>> a=NeverEqual(1)
 >>> a
1
 >>> a==1
False
 >>> a==a
False
 >>> not (a != a)
True
 >>> a!=a
False
 >>>

so I think that assignment doesn't always make things equal even chronologically.
-- 
Robin Becker




More information about the Python-list mailing list