[Python-ideas] Tuple Comprehensions
Alexander Belopolsky
alexander.belopolsky at gmail.com
Tue Oct 18 02:05:54 CEST 2011
On Mon, Oct 17, 2011 at 7:57 PM, Christopher King <g.nius.ck at gmail.com> wrote:
..
>> >>> reduce(operator.concat,(x.strip() for x in xs))
>
> To long for something so simple
.. and how would tuple comprehensions help in this case? A shorter
expression would be
>>> ''.join(x.strip() for x in xs)
For your data, .strip() seems redundant, so
>>> ''.join(xs)
would achieve the same result.
Finally, a more realistic application would want to separate the data somehow:
>>> ','.join(xs)
More information about the Python-ideas
mailing list