>>> data = open('data.txt', 'r') >>> for line in data: ... print len(line) ... 8 6 6 5