Python Equivalent for dd & fold
rylesny at gmail.com
Thu Jul 16 18:23:25 CEST 2009
On Jul 15, 1:14 pm, seldan24 <selda... at gmail.com> wrote:
> On Jul 15, 12:47 pm, Michiel Overtoom <mot... at 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:]
> > s="A very long string indeed. Really that long? Indeed."
> > fold(s,10)
> > Output:
> > A very lon
> > g string i
> > ndeed. Rea
> > lly that l
> > ong? Indee
> > d.
> > Greetings,
> > --
> > "The ability of the OSS process to collect and harness
> > the collective IQ of thousands of individuals across
> > the Internet is simply amazing." - Vinod Valloppillilhttp://www.catb.org/~esr/halloween/halloween4.html
> Wow, I feel like a dork. I should have done more research prior to
> posting. Anyway, thanks for the advice. The trouble with Python is
> that things make 'too much' sense. Loving this language.
You might also find the textwrap module useful:
More information about the Python-list