[FRPythoneers] iterator like inject:into to generating comma-separated list

Cameron Laird claird at starbase.neosoft.com
Mon Sep 16 18:25:25 MDT 2002


> From frpythoneers-admin at lists.community.tummy.com  Mon Sep 16 19:18:22 2002
> Delivered-To: mailman-lists.community.tummy.com-frpythoneers at lists.community.tummy.com
> From: Sean Reifschneider <jafo at tummy.com>
> To: frpythoneers at lists.community.tummy.com
> Subject: Re: [FRPythoneers] iterator like inject:into to generating comma-separated list
> 		.
> 		.
> 		.
> Alternately:

>    >>> list = [1, 'a', 2]
>    >>> reduce(lambda x, y: str(x) + ',' + str(y), list)
>    '1,a,2'

> which will explicitly str() the arguments if they aren't already strings.
> 		.
> 		.
> 		.
I prefer
  string.join(map(str, list), ",") 



More information about the FRPythoneers mailing list