Routine for prefixing '>' before every line of a string

Boris Borcic bborcic at gmail.com
Thu Dec 14 08:03:09 EST 2006


Sanjay wrote:
> Hi All,
> 
> Is somewhere a routine useful to convert a string to lines of maxsize,
> each prefixed with a '>'. This is a typical requirement for 'keeping
> existing text while replying to a post in a forum'.
> 
> It can be developed, but if something obvious is already there(I being
> new to python might not be aware), than it would be great just to reuse
> it!
> 
> thanks
> sanjay
> 

def fixlines(stuff) :
    for line in stuff.split(line_separator) :
        for chunkstart in range(0,len(line),maxsize) :
		yield prefix + line[chunkstart:chunkstart+maxsize]



More information about the Python-list mailing list