dimanche 19 avril 2015

Convert string representation of list of objects back to list in python

I have a list of objects, that has been stringified:



u'[<object: objstuff1, objstuff2>, <object: objstuff1, objstuff2>]'


I want to convert this back into a list:



[<object: objstuff1, objstuff2>, <object: objstuff1, objstuff2>]


I've tried using ast.literal_eval(), but unfortunately, it doesn't seem to work if the elements are objects, and I get a syntax error.


Is there any way I can reconvert my string representation of the list of objects back into a list?


Aucun commentaire:

Enregistrer un commentaire