On Sunday 03 July 2005 07:05 pm, Erik Max Francis wrote: > I personally think that map looks clearer than a list comprehension for > a simple function call, e.g.
I have to disagree > map(str, sequence) This says "call a function 'map' on 'str' and 'sequence'" Which, syntactically, is not terribly informative. I have to remember: * "str" is actually a callable * "map" is a mathematical concept of linking one thing to another. What things? "str to sequence"? No! Wrong guess. "str" is the "mapping function", and the result is the thing sequence is to be linked to. Now, sure, I know all this, and I learned what "map" did from the manual, but it's not especially easy to remember. This on the other hand, > [str(x) for x in sequence] is practically plain English: "call the function "str" on x, for every x in sequence" Other than chopping out a few words, and using the () operator instead of "call", it's hard to imagine this being any closer to exactly what you would say to describe the operation. And for most of us, English comes easier than Computer Science jargon. -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com -- http://mail.python.org/mailman/listinfo/python-list