Naive idiom questions

kdwyer kevin.p.dwyer at gmail.com
Sat Feb 2 12:55:45 EST 2008


On Jan 31, 9:30 pm, Terran Melconian
<te_rem_ra_ove_an_fors... at consistent.org> wrote:
>
>     I want to be able to accumulate a string with +=, not by going
>     through an intermediate list and then doing ''.join(), because I
>     think the latter is ugly.

As others have observed, you can build a string using += instead of
''.join(), but += runs in quadratic time so it's not terribly
efficient if you're building strings out of a lot of elements, or if
the number of elements is arbitrary.

Cheers,

Kev



More information about the Python-list mailing list