For continuity purposes as the original message had been sent via
email...
-=-=-=-=-=-=-=-
Forgive my going direct -- I do not have news posting ability
from work, and won't be home for another three hours. Replies have been
directed to my home address. Once home, I'll post a copy of this message
on the group itself, just for completeness…
Try
"""
Simple procedure to produce space-filled text strings
(left, right, center) for display devices that do not use
new-line control, but instead treat the output as a
single line of data
stripping leading spaces of follow-up lines when left justified
is left as an exercise
"""
LEFTJUST = 1
CENTERED = 2
RIGHTJUST = 3
def fillWrap(text, width=24, mode=LEFTJUST):
output = []
text = " ".join(text.split()) #clean up embedded white space
while text:
if len(text) > width:
(line, text) = (text[:width], text[width:])
spc = line.rfind(" ")
if spc != -1: #-1 means no spaces in the first width
characters
(line, text) = (line[:spc], line[spc:] + text)
else:
line = text
text = None
else:
line = text
text = None
if mode == RIGHTJUST:
line = line.rjust(width)
elif mode == CENTERED:
line = line.center(width)
else:
line = line.ljust(width)
output.append(line)
return "".join(output)
def emulateDisplay(text, width=24):
while text:
(line, text) = (text[:width], text[width:])
print line
print
if __name__ == "__main__":
message = """This is a long and rambling bit of nonsense,
four stone and 10 is a candidate for Top Model.
American Idol\tis a pastime of the American Idle
"""
emulateDisplay(fillWrap(message))
emulateDisplay(fillWrap(message, mode=CENTERED))
emulateDisplay(fillWrap(message, mode=RIGHTJUST, width=30),
width=30)
emulateDisplay(fillWrap(message, width=30), width=30)
============= (used fixed pitch to view)
C:\Documents and Settings\Dennis Lee Bieber>python "e:\UserData\Dennis
Lee Bieber\My Documents\E
udora\Script13.py"
This is a long and
rambling bit of
nonsense, four stone
and 10 is a candidate
for Top Model.
American Idol is a
pastime of the
American Idle
This is a long and
rambling bit of
nonsense, four stone
and 10 is a candidate
for Top Model.
American Idol is a
pastime of the
American Idle
This is a long and rambling
bit of nonsense, four stone
and 10 is a candidate for
Top Model. American Idol is
a pastime of the American
Idle
This is a long and rambling
bit of nonsense, four stone
and 10 is a candidate for
Top Model. American Idol is
a pastime of the American
Idle
C:\Documents and Settings\Dennis Lee Bieber>
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/