Re: Dict Comprehension ?

2008-10-07 Thread Ernst-Ludwig Brust
<[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > > from collections import defaultdict > da=defaultdict(int) > for x in [10]: >for y in [11]: >da[abs(x-y)]+=1 Thangs, collections are a real good idea. I will use this version. Ernsst-Ludwwig Brust -- http://mail.p

Re: Dict Comprehension ?

2008-10-07 Thread Ernst-Ludwig Brust
"Ben Finney" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > "Ernst-Ludwig Brust" <[EMAIL PROTECTED]> writes: > > So, generator expressions can be a powerful way to clarify the purpose > of a section of code. They can be over-used, t

Re: Dict Comprehension ?

2008-10-07 Thread Ernst-Ludwig Brust
. But, i used the idea of pruebauno, as this is faster. Ernst-Ludwig Brust -- http://mail.python.org/mailman/listinfo/python-list

Dict Comprehension ?

2008-10-06 Thread Ernst-Ludwig Brust
Given 2 Number-Lists say l0 and l1, count the various positiv differences between the 2 lists the following part works: dif=[abs(x-y) for x in l0 for y in l1] da={} for d in dif: da[d]=da.get(d,0)+1 i wonder, if there is a way, to avoid the list dif Ernst-Ludwig Brust -- http