Python Equivalent for dd & fold
python at mrabarnett.plus.com
Wed Jul 15 19:23:14 CEST 2009
> 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="A very long string indeed. Really that long? Indeed."
>> A very lon
>> g string i
>> ndeed. Rea
>> lly that l
>> ong? Indee
> 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 still need to tweak the above code as regards how line endings
More information about the Python-list