Last active
December 30, 2015 03:44
-
-
Save paultopia/afbb9fc17ed3674d188d to your computer and use it in GitHub Desktop.
worst_python_ever.py
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
# I think I've discovered a bit of Python code even more dangerous than https://github.com/ajalt/fuckitpy | |
class string(str): | |
def __call__(self): | |
try: | |
exec self | |
except Exception: | |
pass | |
evil = string('print "EVIL"') | |
print evil | |
# produces 'print "EVIL"' | |
print len(evil) | |
# produces 12 | |
evil() | |
# produces 'EVIL' | |
# sadly I don't seem to be able to find a way to rebind the name str itself this way. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment