Gabriel Genellina: > import operator,fileinput > mapper = map(operator.itemgetter, [0,1,20,21,2,10,12,14,11,4,5,6]) > for line in fileinput.input(): > fields = line.split() > print '\t'.join(m(fields) for m in mapper)
I'm just curious, what's the advantage of using itemgetter there compared to something simpler like this (untested!)? import fileinput positions = [0,1,20,21,2,10,12,14,11,4,5,6] for line in fileinput.input(): fields = line.split() print '\t'.join(fields[m] for m in positions) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list