mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-27 06:14:31 +01:00
Fix columnization of lists
This commit is contained in:
parent
e64118e9d3
commit
514125496b
1 changed files with 13 additions and 1 deletions
|
@ -76,6 +76,18 @@ def _sorted(lst, key):
|
||||||
out.sort()
|
out.sort()
|
||||||
return [l.thing for l in out]
|
return [l.thing for l in out]
|
||||||
|
|
||||||
|
def zip_longest(*args):
|
||||||
|
let nargs = len(args)
|
||||||
|
let longest = max(len(a) for a in args)
|
||||||
|
let n = 0
|
||||||
|
while n < longest:
|
||||||
|
let row = []
|
||||||
|
for arg in args:
|
||||||
|
if n < len(arg):
|
||||||
|
row.append(arg[n])
|
||||||
|
yield row
|
||||||
|
n++
|
||||||
|
|
||||||
def _print_columnised(items):
|
def _print_columnised(items):
|
||||||
'''
|
'''
|
||||||
Columnise a list and prints it
|
Columnise a list and prints it
|
||||||
|
@ -90,7 +102,7 @@ def _print_columnised(items):
|
||||||
term_width,
|
term_width,
|
||||||
lambda x: UCS.dispLen(x[0]))
|
lambda x: UCS.dispLen(x[0]))
|
||||||
|
|
||||||
for row in zip(*columns):
|
for row in zip_longest(*columns):
|
||||||
def iter_parts():
|
def iter_parts():
|
||||||
let spacing = 0
|
let spacing = 0
|
||||||
for cell in row:
|
for cell in row:
|
||||||
|
|
Loading…
Reference in a new issue