from tokenize import tokenize
input_file = 'ALL.txt'
output_file = 'ALL1.txt'
MULTI_WORD = -1
word_locations = {}
for pos, word in tokenize(input_file):
if word not in word_locations:
word_locations[word] = pos
else:
word_locations[word] = MULTI_WORD
edit_points = [(pos, len(word)) for word, pos in word_locations.iteritems()
if pos != MULTI_WORD]
start_pos = 0
for end_pos, edit_length in edit_points:
input_file.seek(start_pos)
output_file.write(input_file.read(end_pos - start_pos))
start_pos = end_pos + edit_length
input_file.seek(start_pos)
output_file.write(input_file.read())
В строке for pos, word in tokenize(input_file): появляется ошибка 'str' object is not callable