Usage of ast.

Jon Ribbens jon+usenet at unequivocal.eu
Tue Feb 28 06:17:32 EST 2017


On 2017-02-28, Chris Angelico <rosuav at gmail.com> wrote:
> On Tue, Feb 28, 2017 at 11:35 AM, Jon Ribbens <jon+usenet at unequivocal.eu> wrote:
>> Sorry, I must have missed something here. What are you talking about?
>> "lambda: [1,2,3]" is not acceptable input to ast.literal_eval(), it
>> will throw an exception.
>
> [1,2,3] is, though. Go read my previous posts.

I already did. Perhaps you should too - as well as forgetting what
I have said you seem to be forgetting what you have said! "[1,2,3]" is
both a literal by "my" definition, and is accepted by literal_eval().
There is no mystery there. You brought up the idea of functions
instead, which are neither literals nor accepted by literal_eval()
- no mystery there either.



More information about the Python-list mailing list