I think that understanding lists can give me this, but I'm not sure: are there any elegant solutions in Python (2.6) to select unique objects in a list and provide an account?
(I determined __eq__to determine the uniqueness of the definition of my object).
So, in RDBMS-land, something like this:
CREATE TABLE x(n NUMBER(1));
INSERT INTO x VALUES(1);
INSERT INTO x VALUES(1);
INSERT INTO x VALUES(1);
INSERT INTO x VALUES(2);
SELECT COUNT(*), n FROM x
GROUP BY n;
What gives:
COUNT(*) n
3 1
1 2
So here is my equivalent list in Python:
[1,1,1,2]
And I want to get the same result as SQL SELECT.
EDIT: The example I cited here has been simplified, I actually process lists of custom instance objects: just for completeness, I include the extra code that I need to make it all work:
import hashlib
def __hash__(self):
md5=hashlib.md5()
[md5.update(i) for i in self.my_list_of_stuff]
return int(md5.hexdigest(),16)
set (set), __hash__ ( , 2.6 [ , , (. ) - , ]). my_list_of_stuff - () .