Skip to content
Advertisement

How can I handle eval() exec() multiline as first in first out

I have code from this Question: Why is Python’s eval() rejecting this multiline string, and how can I fix it?

JavaScript

When I use this code:

JavaScript

The result is:

JavaScript

I am expecting this:

JavaScript

How can I change the code? I tried to change the code, but I was not successful.

Advertisement

Answer

The code you’ve posted sorts the ast tree body in 2 buckets, the ast.Exprs and the rest, and then processes them bucket-wise. So, you have to remove the “bucketing”. You could try something like the following:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement