0

I am using commands.getstatusoutput(cmd) to run a command line program that returns a python list. getstatusoutput converts that python list to a string.

_, output = commands.getstatusoutput('mypythonprogram')
print output
'[{1:1,2:2}, {3:3, 4:4}]'

I want to use that output as a regular python list in my program. Is there something similar to json.loads that I can use?

Note: Importing 'mypythonprogram' is not an option.

ghostcoder
  • 443
  • 1
  • 5
  • 16
  • 1
    If I understand the issue correctly, you want to convert a string into the corresponding list of dictionaries. If that's correct, I think [this question](http://stackoverflow.com/questions/988228/converting-a-string-to-dictionary) has a similar solution, using the [ast](https://docs.python.org/2/library/ast.html) library. – Alex S Apr 16 '14 at 18:49
  • Thanks. That is what I was looking for. – ghostcoder Apr 16 '14 at 19:28

0 Answers0