title: How to save AWS CLI command output to var in python?
body: <p>I am trying to save AWS CLI command into python variable (list). The trick is the following code returns result I want but doesn't save it into variable and return empty list.</p>
  
  <pre><code>import os
  bashCommand = 'aws s3api list-buckets --query "Buckets[].Name"'
  f = [os.system(bashCommand)]
  
  print(f)
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>[
  "bucket1",
  "bucket2",
  "bucket3"
  ]
  [0]
  </code></pre>
  
  <p>desired output:</p>
  
  <pre><code>[
  "bucket1",
  "bucket2",
  "bucket3"
  ]
  ("bucket1", "bucket2", "bucket3")
  </code></pre>