Created
November 2, 2013 22:29
-
-
Save garcia/7284193 to your computer and use it in GitHub Desktop.
Swaps the values of False and True under CPython 2.7.5. Unlike the usual "False, True = True, False" prank, this alters the hardcoded values so that even built-in operations which return a boolean (like 1 == 1) return the opposite.
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
import ctypes | |
import sys | |
for b, boolean in enumerate((False, True)): | |
(ctypes.c_char * sys.getsizeof(boolean)).from_address(id(boolean))[8] = chr(1 - b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment