diff -r 4d00d0109147 Lib/string.py --- a/Lib/string.py Wed Jan 07 00:37:01 2015 +1000 +++ b/Lib/string.py Wed Jan 07 00:03:11 2015 +0100 @@ -29,6 +29,21 @@ # Functions which aren't available as string methods. + +def from_iterable(iterable, map_function=None): + """from_iterable(iterable [,map_function]) -> string + + Create a string from the given iterable. The map_function argument specify + a one-argument mapping function that will be applied to each element of the + iterable. In any way the str() constructor will be applied to each element, + after the transformation. + + """ + if map_function is None: + map_function = lambda x: x + return "".join(str(map_function(el)) for el in iterable) + + # Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def". def capwords(s, sep=None): """capwords(s [,sep]) -> string