ast.literal_eval() support for set literals in Python 2.7?
问题 In the What’s New in Python 2.7 document it says that support for set literals was back-ported from Python 3.1. However it appears that this support was not extended to the ast module's literal_eval() function, as illustrated below. Was this intentional, an oversight, or something else -- and what are the cleanest workarounds for creating a literal set from a string representation? (I assume the following works in Python 3.1+, right?) import ast a_set = {1,2,3,4,5} print a_set print ast