question about list extension
J. Cliff Dyer
jcd at sdf.lonestar.org
Fri Apr 16 10:59:12 EDT 2010
On Sat, 2010-04-17 at 00:37 +1000, Lie Ryan wrote:
> On 04/16/10 23:41, J wrote:
> > So, what I'm curious about, is there a list comprehension or other
> > means to reduce that to a single line?
>
> from itertools import chain
> def printout(*info):
> print '\n'.join(map(str, chain(*info)))
>
> or using generator comprehension
>
> from itertools import chain
> def printout(*info):
> print '\n'.join(str(x) for x in chain(*info))
It's even easier if you don't need to modify lista.
print lista + listb
More information about the Python-list
mailing list