You can use a format that will allow each element to be shaped as you wish:
>>> print '\n'.join('{:>10}'.format(e) for e in iter([1,2,'1','2',{1:'1'}])) 1 2 1 2 {1: '1'}
Each element does not have to be a string, but it must have a __repr__ method if it is not a string.
Then you can easily write the desired function:
>>> def printall(it,w): print '\n'.join('{:>{w}}'.format(e,w=w) for e in it) >>> printall([1,2,'3','4',{5:'6'}],10) 1 2 3 4 {5: '6'}
I use a list, but any iterable will do.
user648852
source share