A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/1999-June/095422.html below:

[Python-Dev] join()

[Python-Dev] join()Ka-Ping Yee ping at lfw.org
Sat Jun 12 10:12:38 CEST 1999
On Fri, 11 Jun 1999, Skip Montanaro wrote:
> 
>     BAW> The only reason for making it a builtin would be to avoid pulling
>     BAW> in all of string just to get join.
> 
> I still don't understand the motivation for making it a builtin instead of a
> method of the types it operates on.  Making it a builtin seems very
> un-object-oriented to me.

Builtin-hood makes it possible for one method to apply to
many types (or a heterogeneous list of things).

I think i'd support the

    def join(list, sep=None):
        if sep is None:
            result = list[0]
            for item in list[1:]:
                result = result + item
        else:
            result = list[0]
            for item in list[1:]:
                result = result + sep + item

idea, basically a reduce(operator.add...) with an optional
separator -- *except* my main issue would be to make sure that
the actual implementation optimizes the case of joining a
list of strings.  string.join() currently seems like the last
refuge for those wanting to avoid O(n^2) time when assembling
many small pieces in string buffers, and i don't want it to
see it go away.



!ping



More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4