String concatenation
Paul Rubin
http
Sat Apr 3 04:26:51 EST 2004
"Leif B. Kristensen" <junkmail at solumslekt.org> writes:
> > tmp = [x for x in res if x and x[0] != '-']
> > return ', '.join(tmp)
>
> Substituting tmp with the real thing, it turns into a one-liner:
>
> return ', '.join([x for x in res if x and x[0] != '-'])
>
> Awesome :-)
Yeah, I wrote it that way at first, but figured it was obscure enough
already if you weren't used to list comprehensions, so I put back the
tmp variable.
More information about the Python-list
mailing list