I am referring to a post here Pretty printing a list in a tabular format
mylist = [ ( (12, 47, 4, 574862, 58, 7856), 'AGGREGATE_VALUE1'),
( (2, 75, 757, 8233, 838, 47775272785), 'AGGREG2'),
( (4144, 78, 78965, 778, 78578, 2), 'AGGREGATE_VALUE3')]
header = ('Price1','Price2','reference','XYD','code','resp','AGGREG values')
longg = dict(zip((0,1,2,3,4,5,6),(len(str(x)) for x in header)))
for tu,x in mylist:
longg.update(( i, max(longg[i],len(str(el))) ) for i,el in enumerate(tu))
longg[6] = max(longg[6],len(str(x)))
fofo = ' | '.join('%%-%ss' % longg[i] for i in xrange(0,7))
print '\n'.join((fofo % header,
'-|-'.join( longg[i]*'-' for i in xrange(7)),
'\n'.join(fofo % (a,b,c,d,e,f,g) for (a,b,c,d,e,f),g in mylist)))
I want to replace '\n'.join(fofo % (a,b,c,d,e,f,g) for (a,b,c,d,e,f),g in mylist)))
with something dynamic.
For example range1 = ', '.join(map(chr, range(97, 97+7)))
which gives me a,b,c,d,e,f,g
so the line will look '\n'.join(fofo % (range1) for (a,b,c,d,e,f),g in mylist)))
but gives me:
TypeError: not enough arguments for format string