newbie question concerning formatted output

Micah Elliott mde at micah.elliott.name
Tue Nov 29 15:02:04 EST 2005


On Nov 29, Fredrik Lundh wrote:
> inp = open("xyplan.nobreaks","r")
> data = inp.read()
> 
> import textwrap
> for line in textwrap.wrap(data, 15):
>     print line

Right -- if the data is that regular then every 15th item is the
split-point.  A variation on this theme then is:

    for i in range(0, len(data), 15):
        print data[i:i+15]

-- 
_ _     ___
|V|icah |- lliott             <><             mde at micah.elliott.name
" "     """



More information about the Python-list mailing list