Printing with interspersed element

Grant Edwards invalid at invalid
Thu Oct 30 17:18:59 EDT 2008


On 2008-10-30, Paulo J. Matos <pocmatos at gmail.com> wrote:

>> print ' 10 '.join(str(x) for x in lst)
>
> Thanks for the tip but that has an issue when dealing with potentially
> millions of objects. You are creating a string in memory to then dump
> to a file [or screen] while you could dump to the file [or screen] as
> you go through the original string. Right?

Right, but your original post didn't specify that you had
millions of items.  The best solution for a few dozen or a few
hundred items is often different the the best solution for
millions of items.

The more accurate your question, the more useful the replies.

-- 
Grant Edwards                   grante             Yow! I haven't been married
                                  at               in over six years, but we
                               visi.com            had sexual counseling every
                                                   day from Oral Roberts!!



More information about the Python-list mailing list