Re: [OVC-demo-team] Random ballot generator

From: Jan Karrman <jan_at_it_dot_uu_dot_se>
Date: Sat Mar 06 2004 - 13:23:04 CST

On Sat, 6 Mar 2004, David Mertz wrote:

> In general, the right way to concatenate a bunch of strings in Python
> is either:
>
> (1) Append to a list, then join the list at the end:
>
> lines = []
> for thing in stuff:
> lines.append(doSomething(thing))
> return '\n'.join(lines)
>
> (2) Use cStringIO to buffer lines:
>
> from cStringIO import StringIO
> buf = StringIO()
> for thing in stuff:
> buf.write(doSomething(thing)+"\n")
> return buf.getvalue()
>

Thanks for the tips!

You may recall that I did not know Python at all when I joined the
project. I still haven't read any book on the subject - do you know
of any good one? ;-)

/Jan
==================================================================
= The content of this message, with the exception of any external
= quotations under fair use, are released to the Public Domain
==================================================================
Received on Thu Apr 1 02:40:25 2004

This archive was generated by hypermail 2.1.8 : Thu Apr 01 2004 - 02:40:36 CST