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

Discussion in 'Python' started by Terry Jan Reedy, Apr 22, 2013.

  1. On 4/21/2013 1:12 PM, Lele Gaifax wrote:
    > "Robert Yacobellis" <> 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/...it-string-joinlist-instead-of-list-joinstring
    >
    > ciao, lele.
    >
    Terry Jan Reedy, Apr 22, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ishwor
    Replies:
    2
    Views:
    334
    Nick Coghlan
    Dec 27, 2004
  2. Daniel Mark
    Replies:
    9
    Views:
    12,429
    Simon Brunning
    Sep 19, 2006
  3. AEB
    Replies:
    1
    Views:
    255
    Marc 'BlackJack' Rintsch
    Oct 28, 2008
  4. Robert Yacobellis
    Replies:
    1
    Views:
    153
    Steven D'Aprano
    Apr 21, 2013
  5. Lele Gaifax
    Replies:
    0
    Views:
    124
    Lele Gaifax
    Apr 21, 2013
Loading...

Share This Page