On 08/14/2011 11:28 PM, Seebs wrote:
I tend to write stuff like

        foo.array_of_things.sort.map { block }.join(", ")

I like this a lot more than
        array = foo.array_of_things
        sorted_array = array.sort()
        mapped_array = [block(x) for x in sorted_array]
        ", ".join(mapped_array)

If you like the one-liner, this is readily written as

  ", ".join(block(x) for x in sorted(foo.array_of_things))

Modulo your gripes about string.join(), this is about as succinct (and more readable, IMHO) as your initial example. I've got piles of these sorts of things in my ETL code.

-tkc




--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to