Python: search numbers in a file and sum them

## python assigment from Using Python to Access Web Data, sum numbers in file
import re
file = open('regex_sum_215939.txt')
 num = list()
 for line in file:
aux = re.findall('[0-9]+', line)
  num.extend(aux)
print (sum(int(i) for i in num))
Advertisements