list comprehention

Duncan Booth duncan.booth at invalid.invalid
Mon Jan 23 13:03:42 EST 2006


Mathijs wrote:

> Op 20 jan 2006 vond Duncan Booth <duncan.booth at invalid.invalid>: 
>> Or in other words, define a function to return a dictionary
>> containing a count of the number of occurrences of each element in
>> the list (this assumes that the list elements are hashable). Then you
>> just add up the values in the test list making sure each count is
>> limited to no higher than the reference count.
> 
> Thanks. Though I don't know much about python (yet), this is more or
> less the way I'de do it the language I'm more comfortable with (object
> pascal), and I wouldn't label this as a pythonic solution. I could be
> wrong, though:)
> 
I'm curious what you think isn't pythonic about this solution?



More information about the Python-list mailing list