On 4/21/2013 1:12 PM, Lele Gaifax wrote:
"Robert Yacobellis" <ryacobel...@luc.edu> writes:
I've noticed that the str join() method takes an iterable,
Specifically, it takes an iterable of strings. Any iterable can be made
such iwth map(str, iterable) or map(repr, iterble).
>> so in the
most general case I'm suggesting to add a join() method to every
Python-provided iterable (however, for split() vs. join()
.split *could* have been changed in 3.0 to return an iterator rather
than a list, as done with map, filter, and others. An itersplit method
*might* be added in the future.
it would be
sufficient to just add a join() method to the list class).
That's the reasoning behind the rejection: to be friendly enough, you'd
need to include the "join" method in the "sequence protocol", and
implement it on every "sequence-like" object (be it some kind of
UserList, or a generator, or an interator...)
Plus, only lists of strings can be joined, not generic lists.
This question carries several references to the various threads on the
subject:
http://stackoverflow.com/questions/493819/python-join-why-is-it-string-joinlist-instead-of-list-joinstring
ciao, lele.
--
http://mail.python.org/mailman/listinfo/python-list