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

Peter Otten __peter__ at web.de
Thu Dec 14 08:15:52 EST 2006


Sanjay wrote:

> 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'.

>>> import textwrap
>>> format = textwrap.TextWrapper(20, initial_indent="] ",
subsequent_indent="] ").fill
>>> print format("alpha beta gamma delta\nepsilon zeta eta theta")
] alpha beta gamma
] delta epsilon zeta
] eta theta

Peter




More information about the Python-list mailing list