Substitute for join()

Sean 'Shaleh' Perry shaleh at valinux.com
Wed Mar 21 21:09:05 CET 2001


On 21-Mar-2001 Daniel Klein wrote:
> I've got to make a script (written in version 2.0) to work on a machine
> running 1.5.2. The only incompatible line is one that uses the
> "".join(mylist) method. To 'get out of the woods' quickly, I substituted it
> with
> 
> s = ''
> for element in mylist: s = s + element
> 
> Is this the most efficient way to code this?
> 

or use the syntax that works in both:

import string # or from string import join

string.join(mylist, "")




More information about the Python-list mailing list