text wrapping help
Sick Monkey
sickcodemonkey at gmail.com
Wed Feb 28 20:10:11 EST 2007
I am not certain if I understand your problem, but I think you are just
trying to read in a string and create a visable matrix. If that is true,
then may some of the code below will work. This is in no way elegant.
++++++++++++++++++++++++++++++++++++++++++
count = 1
width = 2 #the width of your matrix
string="aaaaaaaaaa" #input string to piece up
final="" #output string
for character in string:
if count == width :
final = "%s%s\n" % (final,character)
count = 1
else:
final = "%s%s" % (final,character)
count += 1
print final
On 28 Feb 2007 16:06:08 -0800, Ryan K <ryankaskel at gmail.com> wrote:
>
> I'm trying to text wrap a string but not using the textwrap module. I
> have 24x9 "matrix" and the string needs to be text wrapped according
> to those dimensions. Is there a known algorithm for this? Maybe some
> kind of regular expression? I'm having difficulty programming the
> algorithm. Thanks,
> Ryan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070228/c16061d8/attachment.html>
More information about the Python-list
mailing list