Substitute for join()
Siggy Brentrup
bsb at winnegan.de
Wed Mar 21 15:08:18 EST 2001
"Daniel Klein" <DanielK at jBASE.com> writes:
> 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?
Nope, use
import string
string.join(mylist,'')
HIH
Siggy
--
Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/
****** ceterum censeo javascriptum esse restrictam *******
More information about the Python-list
mailing list