Last active
August 29, 2015 14:24
-
-
Save agausmann/b236e9a1c07b2cb1e035 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import keyword | |
def eval_cmd(expr): | |
try: | |
for kw in keyword.kwlist: | |
if kw in expr: | |
return None | |
for word in dir(): | |
if word in expr: | |
return None | |
return eval(expr) | |
except Exception as e: | |
return str(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment