I am writing some sort of simple web-interpreter for vk.com . I look for messages, check if they are valid Python code, and then I want to execute that code, and return any stdout to code sender. I have implemented anything but code checker.
import ast
def is_valid(code):
try:
ast.parse(code)
except SyntaxError:
print('Input isnt code.')
return False
print('Code is ok.')
return True
is_valid() always return True regardless of what comes in. Im really confused...
True.