I have a class named record, which stores information of log record;
class Record():
def __init__(self, **kwargs):
for key, value in kwargs.items():
setattr(self, key, value)
And examples of this record can be:
r1 = Record(uid='001',url='www.google.com',status=200)
r2 = Record(uid='002',url='www.google.com',status=404)
r3 = Record(uid='339',url='www.ciq.com', status=200)
...
What I want is to count how many users each url has. So for "google", there are '001' and '002'. I usually use a Counter to record elements within a list and their appearances. But here, Counter seems just put the elements instead of counting them. Is there a lambda I can put or try?
I can go through all the staff though...
I think i may cause confusion here.
My key point is to group the objects by its attributes...So not only the url counting but also,
res = Counter(r)
(don't know how to put lambda inside or even that's possible) I can get maybe
res[0].url = 'www.google.com'
and its count is 2..?
And suggestion?
Thanks!