[Python-ideas] [...].join(sep)

Oleg Broytman phd at phdru.name
Sat May 12 10:37:08 CEST 2012


On Sat, May 12, 2012 at 11:21:17AM +0300, anatoly techtonik <techtonik at gmail.com> wrote:
> I am certain this was proposed many times

   Thousands.

>     string.join() produces list, why list.join() couldn't produce strings?

   string.split() produces list.

   There is no list.join() because list is only one of many containers.
Should tuple has its own .join() method? What about other containers?
iterables? generators?
   string.join() can accept any iterable, not only a list. That's the
explanation why it's preferred.

>     that means you still get exception when trying to join lists with
> no strings inside

   In what way do you expect list.join(string) would help?

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.



More information about the Python-ideas mailing list