Skip to content

Instantly share code, notes, and snippets.

@paultopia
Last active December 30, 2015 03:44
Show Gist options
  • Save paultopia/afbb9fc17ed3674d188d to your computer and use it in GitHub Desktop.
Save paultopia/afbb9fc17ed3674d188d to your computer and use it in GitHub Desktop.
worst_python_ever.py
# 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