[FRPythoneers] iterator like inject:into to generating comma-separated list
claird at starbase.neosoft.com
Mon Sep 16 17:34:07 MDT 2002
> From frpythoneers-admin at lists.community.tummy.com Mon Sep 16 18:29:21 2002
> Delivered-To: mailman-lists.community.tummy.com-frpythoneers at lists.community.tummy.com
> From: Wostenberg <pwos at attbi.com>
> I need to emit a list of comma separated values such as
> The over-simplification is
> for element in someList:
> someCsv = someCsv + element + ','
> which generates the extra comma at the end of list, which can be
> supressed by additional tests.
> But I remember reading somewhere a special iterator in Python, rather
> like Smalltalk's inject:into, which could eliminate the special test.
> Know what I mean?
Is this it?
Python 1.5.2 (#2, Dec 30 1999, 23:29:24) [GCC 220.127.116.11] on freebsd3
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> my_list = ["a", "b", "c"]
>>> import string
>>> string.join(my_list, ",")
>>> string.join(my_list, ":")
More information about the FRPythoneers