title: Converting lists of digits stored as strings into integers Python 2.7
body: <p>Among other things, my project requires the retrieval of distance information from file, converting the data into integers, then adding them to a 128 x 128 matrix. </p>
  
  <p>I am at an impasse while reading the data from line.</p>
  
  <p>I retrieve it with:</p>
  
  <pre><code>distances = []
  
  with open(filename, 'r') as f:
      for line in f:
          if line[0].isdigit():
              distances.extend(line.splitlines())`
  </code></pre>
  
  <p>This produces a list of strings. </p>
  
  <p>while</p>
  
  <pre><code>int(distances) #does not work
  
  int(distances[0]) # produces the correct integer when called through console
  </code></pre>
  
  <p>However, the spaces foobar the procedure later on.
  An example of list:</p>
  
  <pre><code>['966']['966', '1513' 2410'] # the distance list increases with each additional city. The first item is actually the distance of the second city from the first. The second item is the distance of the third city from the first two. 
  
  int(distances[0]) #returns 966 in console. A happy integer for the matrix. However:
  int(distances[1]) # returns:
  </code></pre>
  
  <blockquote>
    <p>Traceback (most recent call last):
     File "", line 1, in 
    ValueError: invalid literal for int() with base 10: '1513 2410'</p>
  </blockquote>
  
  <p>I have a slight preference for more pythonic solutions, like list comprehension and the like, but in reality- any and all help is greatly appreciated.</p>
  
  <p>Thank you for your time.</p>