a = """
A = 5
if A > 0 :
print("A Is Positive")
elif A == 0 :
print("A Is Equal To 0")
else :
print("A Is Negative")
"""
exec(a)
>>> A Is Positive
#you can also use eval(string) for asyncio
Just use eval command for running string output. Asfor example:
eval $cmd #execute command included in string value of $cmd variableOrfor a more sophisticated use run commands storedinlinesof a file:
cat commands_file.txt | whileread line; do eval $line; done