title: Filtering out strings that only contains digits and/or punctuation - python
body: <p>I need to filter out only strings that contains only digits and/or a fix set of punctuation. </p>
  
  <p>I've tried checking each character and then summing the Boolean conditions to check if it is equal to the <code>len(str)</code>. Is there a more pythonic way to do this:</p>
  
  <pre><code>&gt;&gt;&gt; import string
  &gt;&gt;&gt; x = ['12,523', '3.46', "this is not", "foo bar 42", "23fa"]
  &gt;&gt;&gt; [i for i in x if [True if j.isdigit() else False for j in i] ]
  ['12,523', '3.46', 'this is not', 'foo bar 42']
  &gt;&gt;&gt; [i for i in x if sum([True if j.isdigit() or j in string.punctuation else False for j in i]) == len(i)]
  ['12,523', '3.46']
  </code></pre>