I have a (massive) list represented as a string (not like this, this is just an example)
"['A', 'B', 'C']"
and I need to make it a list type:
['A', 'B', 'C']
but if I do:
list("['A', 'B', 'C']")
obviously I'll get:
['[', "'", 'A', "'", ',', ' ', "'", 'B', "'", ',', ' ', "'", 'C', "'", ']']
Currently I'm using:
ast.literal_eval("['A', 'B', 'C']")
Except that the lists which my program is handling are huge, and the strings are millions of bytes (the test string is over 4 million characters). So my ast.literal_eval() is returning a MemoryError whenever I try to run it.
What I need therefore is a way (it doesn't have to be pythonic, elegant or even particularly efficient) to make these huge strings into lists without returning a memerror.