Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44029

Re: suggestion for a small addition to the Python 3 list class

From Terry Jan Reedy <tjreedy@udel.edu>
Subject Re: suggestion for a small addition to the Python 3 list class
Date 2013-04-21 21:44 -0400
References <5173ACC00200007C000B7024@gwiawt1.is-svr.luc.edu> <87vc7fvmdf.fsf@nautilus.nautilus>
Newsgroups comp.lang.python
Message-ID <mailman.894.1366595053.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 4/21/2013 1:12 PM, Lele Gaifax wrote:
> "Robert Yacobellis" <ryacobellis@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.
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: suggestion for a small addition to the Python 3 list class Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-21 21:44 -0400

csiph-web