title: Python: Iterate through a list and only print out variables that are arrays?
body: <p>I have the following example data and list:</p>
  <pre><code>data.var1 = np.array([1, 2, 3])
  data.var2 = 30
  data.var3 = 10
  allvariables = [data.var1, data.var2, data.var3]
  </code></pre>
  <p>Where any one of the vars could be either an array or just a number. (The data from above is just an example) I want to iterate through the allvariables list and add all the arrays to a new list.</p>
  <p>This is what I have tried so far:</p>
  <pre><code>arrayvariables = [vname for vname, i in vars(data).items() if isinstance(i, np.ndarray)]
  </code></pre>
  <p>But this adds the variable name as a string to the arrayvariables list. (ex:
  &quot;var1&quot;)</p>
  <p>I have also tried</p>
  <pre><code>arrayvariables = [vars(data).get(vname) for vname in allvariables if isinstance(vars(data).get(vname), np.ndarray)]
  </code></pre>
  <p>But this just adds the array value to the list. (ex: array([1, 2, 3]))</p>
  <p>What I want is for the arrayvariables list to be the same as what the following code would create (assuming data.var1 is the only array):</p>
  <pre><code>arrayvariables = [data.var1]
  </code></pre>
  <p>I am fairly new to Python, so I may just be missing something obvious.</p>
  <p>Thanks</p>