On 7/15/2009 10:23 AM MRAB said...
On Jul 15, 12:47 pm, Michiel Overtoom <mot...@xs4all.nl> wrote:
seldan24 wrote:
what can I use as the equivalent for the Unix 'fold' command?
def fold(s,len):
     while s:
         print s[:len]
         s=s[len:]

<snip>
You might still need to tweak the above code as regards how line endings
are handled.

You might also want to tweak it if the strings are _really_ long to simply slice out the substrings as opposed to reassigning the balance to a newly created s on each iteration.

Emile

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to