Skip to content

Instantly share code, notes, and snippets.

@mvanveen
Created November 16, 2011 06:47
Show Gist options
  • Save mvanveen/1369459 to your computer and use it in GitHub Desktop.
Save mvanveen/1369459 to your computer and use it in GitHub Desktop.
eval() thyself and recurse anew
eval("""
eval(__import__('inspect').getsource(
__import__(
__import__('os').path.relpath(
__import__('os').path.splitext(__file__)[0]
))))
""")
@mvanveen
Copy link
Author

⚠️ The modification below will segfault python.

eval("""
eval(not __import__('sys').setrecursionlimit(
 __import__('sys').getrecursionlimit() + 2
 ) and __import__('inspect').getsource(
 __import__(
  __import__('os').path.relpath( 
   __import__('os').path.splitext(__file__)[0]
))))
""")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment