title: Remove unwanted characters and convert to int in Python
body: <p>What is the best way to read in a line of numbers from a file when they are presented in a format like this:</p>
  
  <pre><code>[1, 2, 3 , -4, 5]
  [10, 11, -12, 13, 14 ]
  </code></pre>
  
  <p>Annoyingly, as I depicted, sometimes there are extra spaces between the numbers, sometimes not. I've attempted to use <code>CSV</code> to work around the commas, but the brackets and the random spaces are proving difficult to remove as well. Ideally I would append each number between the brackets as an <code>int</code> to a <code>list</code>, but of course the brackets are causing <code>int()</code> to fail.</p>
  
  <p>I've already looked into similar solutions suggested with <a href="https://stackoverflow.com/questions/2780904/removing-unwanted-characters-from-a-string-in-python/" title="this">Removing unwanted characters from a string in Python</a> and <a href="https://stackoverflow.com/questions/19201575/python-read-file-look-up-a-string-and-remove-characters">Python Read File, Look up a String and Remove Characters</a>, but unfortunately I keep falling short when I try to combine everything.</p>