mirror of
https://github.com/python/cpython.git
synced 2025-10-18 04:38:07 +00:00
printlist(): Replaced the guts with a call to textwrap. Yay!
This commit is contained in:
parent
8b7f131f8b
commit
ba78bc4a32
1 changed files with 19 additions and 30 deletions
|
@ -464,21 +464,10 @@ def printlist(x, width=70, indent=4):
|
|||
begin each line.
|
||||
"""
|
||||
|
||||
line = ' ' * indent
|
||||
for one in map(str, x):
|
||||
w = len(line) + len(one)
|
||||
if line[-1:] == ' ':
|
||||
pad = ''
|
||||
else:
|
||||
pad = ' '
|
||||
w += 1
|
||||
if w > width:
|
||||
print line
|
||||
line = ' ' * indent + one
|
||||
else:
|
||||
line += pad + one
|
||||
if len(line) > indent:
|
||||
print line
|
||||
from textwrap import fill
|
||||
blanks = ' ' * indent
|
||||
print fill(' '.join(map(str, x)), width,
|
||||
initial_indent=blanks, subsequent_indent=blanks)
|
||||
|
||||
class _Set:
|
||||
def __init__(self, seq=[]):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue