map() return of flat tuple list

bearophileHUGS at bearophileHUGS at
Fri Jun 23 11:11:02 CEST 2006

>He, this looks more like Haskell than like Python (for me, it looks awful ;-)

Maybe this is more readable:

ar = [[3,3,3,3],

print sorted( [(r,c) for r,row in enumerate(ar) for c in
              key=lambda (r,c): ar[r][c]

I don't know if operator.itemgetter can be used here, I think it's too
much complex.

With python 2.5 you can probably simplify it a little (and speed it up)
with something like:

print min( [ (r,c) for r,row in enumerate(ar) for c in xrange(len(row))
           key=lambda (r,c): arr[r][c]


More information about the Python-list mailing list