ValueError: too many values to unpack in a tuple
Posted
by
falosi
on Stack Overflow
See other posts from Stack Overflow
or by falosi
Published on 2012-10-04T15:06:50Z
Indexed on
2012/10/04
15:38 UTC
Read the original article
Hit count: 255
python
|python-2.7
Please put some light on why am getting a too many to unpack (ValueError in my for loop).Have tried deb
naislist = [('CONTROL FILE', '0', '0', '0'),
('REDO LOG', '0', '0', '0'),
('ARCHIVED LOG', '.69', '.59', '3'),
('BACKUP PIECE', '46.54', '0', '192'),
('IMAGE COPY', '0', '0', '0'),
('FLASHBACK LOG', '10.15', '6.31', '82'),
('FOREIGN ARCHIVED LOG', '0', '0', '0')]
print "size of naislist is ",len((naislist))
heading = ('MAIN MENU', 'LEVELS', 'LEVEL2', 'LEVEL3')
rearrange = dict(zip((0, 1, 2, 3), (len(str(x)) for x in heading)))
for tu, x in naislist:
rearrange.update((i, max(rearrange[i], len(str(el)))) for i, el in enumerate(tu))
rearrange[4] = max(rearrange[4], len(str(x)))
forkit = '|'. join('%%-%ss' % rearrange[i] for i in xrange(0, 4))
print '\n'.join((forkit % heading,
'-|-'.join(rearrange[i] * '-' for i in xrange(4)),
'\n'.join(forkit % (a, b, c, d) for (a, b, c), d in naislist)))
© Stack Overflow or respective owner