wrapString(): defaults and tests

This commit is contained in:
Rolux 2008-07-06 12:34:09 +02:00
parent e52cb82e86
commit 0f4d51f3ba
1 changed files with 7 additions and 1 deletions

View File

@ -62,7 +62,13 @@ def wrap(text, width):
text.split(' ')
)
def wrapString(string, length, separator, balance):
def wrapString(string, length=80, separator='\n', balance=False):
'''
>>> wrapString("Anticonstitutionellement, Paris s'eveille", 16)
"Anticonstitution\nellement, Paris \ns'eveille"
>>> wrapString('All you can eat', 12, '\n', True)
'All you \ncan eat'
'''
if balance:
# balance lines: test if same number of lines
# can be achieved with a shorter line length