On Jun 19, 5:17 am, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote: > > persons.count("olle", key = attergetter("name")) > > is longer and just barely more readable than > > sum(1 for x in persons if x.name == "olle")) >
The OP's proposal seems to have a very narrow focus, whereas the generator approach can handle a much wider range of queries: sum(1 for x in persons if x.name == "olle" and x.country == "se")) sum(x.salary for x in persons if x.name == "olle")) By the time one has looked up the syntax for the augmented count method, remembered the existence of something like "attergetter" [sic] and nutted out its spelling and usage, somebody else using generators would have the job and gone to lunch :-) YAGNI. Case dismissed. -- http://mail.python.org/mailman/listinfo/python-list