John Posner wrote:
...This solution relies on the object ID -- no hashability required:
# get list of object-IDs
ids = map(lambda x: id(x), mylist)
# ALL THE SAME? ... test whether "average ID" matches "first ID"
sum(ids)/len(ids) == ids[0]
Assuming you really are going for "is" comparison, how about:
max(id(x) for x in mylist) == min(id(x) for x in mylist)
It has the advantage that if [id(x) for x in mylist] = [2N, 1N, 3N],
you get the answer you desire.
--Scott David Daniels
[email protected]
--
http://mail.python.org/mailman/listinfo/python-list