This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author youtux
Recipients youtux
Date 2015-01-06.23:27:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420586838.31.0.418706320174.issue23179@psf.upfronthosting.co.za>
In-reply-to
Content
I would like to suggest a new string function/constructor: 
string.from_iterable(iterable [,map_function])

I think that the behaviour is intuitive: given an iterable, it construct a string using its element by apply a `map_function`, if provided, to each one of them. After that the str() constructor will be applied to each element in any way, to ensure that effectively an iterable of strings is used.

Of course I do not expect that you will accept this patch, but I think this really is a missing piece of the python library.

You can argue that I could just use
"".join(iterable)
but in my opinion there are two problems:
1) if any of the elements of `iterable` is not a `str` instance, it will fail miserably;
2) this is not very pythonic.

This issue is meant to be an idea for the python maintainers, so I did not write the corresponding `Doc/libary/string.rst` documentation, but if you are interested I could do it.

Thank you people for your amazing work.
History
Date User Action Args
2015-01-06 23:27:18youtuxsetrecipients: + youtux
2015-01-06 23:27:18youtuxsetmessageid: <1420586838.31.0.418706320174.issue23179@psf.upfronthosting.co.za>
2015-01-06 23:27:18youtuxlinkissue23179 messages
2015-01-06 23:27:18youtuxcreate