A RetroSearch Logo

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

Search Query:

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

[Python-Dev] String methods... finally

[Python-Dev] String methods... finallyDavid Ascher da at ski.org
Fri Jun 11 07:09:46 CEST 1999
On Fri, 11 Jun 1999, Skip Montanaro wrote:

> It occurred to me just a few minutes after sending my previous message that
> it might make sense to make string.join a method for lists and tuples.
> They'd obviously have to make the same type checks that string.join does.

as in:

   >>> ['spam!', 'eggs!'].join()
   'spam! eggs!'

?  

I like the notion, but I think it would naturally migrate towards
genericity, at which point it might be called "reduce", so that:

   >>> ['spam!', 'eggs!'].reduce()
   'spam!eggs!'
   >>> ['spam!', 'eggs!'].reduce(' ')
   'spam! eggs!'
   >>> [1,2,3].reduce()
   6  # 1 + 2 + 3
   >>> [1,2,3].reduce(10)
   26 # 1 + 10 + 2 + 10 + 3

note that string.join(foo) == foo.reduce(' ')
     and  string.join(foo, '') == foo.reduce()

--david




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