summaryrefslogtreecommitdiffstats
path: root/Lib/string.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-11-26 08:21:35 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-11-26 08:21:35 (GMT)
commit4f8f9765766a126ebfff3c81655454821f1ad532 (patch)
tree90f6c08e42a551b8bb461d191afddaef5e4f0cf4 /Lib/string.py
parentbd93b3ea8fd87742dd56c9c1ff514223892e0d4a (diff)
downloadcpython-4f8f9765766a126ebfff3c81655454821f1ad532.zip
cpython-4f8f9765766a126ebfff3c81655454821f1ad532.tar.gz
cpython-4f8f9765766a126ebfff3c81655454821f1ad532.tar.bz2
Add optional fillchar argument to ljust(), rjust(), and center() string methods.
Diffstat (limited to 'Lib/string.py')
-rw-r--r--Lib/string.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 5b5ddc3..0a77f46 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -237,37 +237,37 @@ def atol(s, base=10):
# Left-justify a string
-def ljust(s, width):
- """ljust(s, width) -> string
+def ljust(s, width, *args):
+ """ljust(s, width[, fillchar]) -> string
Return a left-justified version of s, in a field of the
specified width, padded with spaces as needed. The string is
- never truncated.
+ never truncated. If specified the fillchar is used instead of spaces.
"""
- return s.ljust(width)
+ return s.ljust(width, *args)
# Right-justify a string
-def rjust(s, width):
- """rjust(s, width) -> string
+def rjust(s, width, *args):
+ """rjust(s, width[, fillchar]) -> string
Return a right-justified version of s, in a field of the
specified width, padded with spaces as needed. The string is
- never truncated.
+ never truncated. If specified the fillchar is used instead of spaces.
"""
- return s.rjust(width)
+ return s.rjust(width, *args)
# Center a string
-def center(s, width):
- """center(s, width) -> string
+def center(s, width, *args):
+ """center(s, width[, fillchar]) -> string
Return a center version of s, in a field of the specified
width. padded with spaces as needed. The string is never
- truncated.
+ truncated. If specified the fillchar is used instead of spaces.
"""
- return s.center(width)
+ return s.center(width, *args)
# Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03'
# Decadent feature: the argument may be a string or a number