Mathijs wrote: > Op 20 jan 2006 vond Duncan Booth <[EMAIL PROTECTED]>: >> 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:)
You *are* wrong. Also, as the lists grow, Duncan's approach scales *much* better than, e. g., mine. If picking a better algorithm were unpythonic there would not be much value in striving for pythonic solutions. Peter -- http://mail.python.org/mailman/listinfo/python-list