wrapString(): defaults and tests
This commit is contained in:
parent
e52cb82e86
commit
0f4d51f3ba
1 changed files with 7 additions and 1 deletions
|
@ -62,7 +62,13 @@ def wrap(text, width):
|
||||||
text.split(' ')
|
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:
|
if balance:
|
||||||
# balance lines: test if same number of lines
|
# balance lines: test if same number of lines
|
||||||
# can be achieved with a shorter line length
|
# can be achieved with a shorter line length
|
||||||
|
|
Loading…
Reference in a new issue