casting string content to list [duplicate]

Let's assume I have list, and have turned it into a string (to use it as a dictionary key for example). Is there a way to get the list back from the string? This code snippet should illustrate what I want:

list_str = str([1,2,3])
my_list = some_operation(list_str)

such that the variable my_list contains the list [1,2,3]

Any help would be appreciated!

Read more here:

Content Attribution

This content was originally published by Nicolas at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: