Created
July 26, 2014 18:32
-
-
Save DavidJFelix/d5a100f0a38400f30995 to your computer and use it in GitHub Desktop.
Modify python behavior
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
from ctypes import c_int8 | |
from struct import calcsize | |
# Make 4 = 5 | |
c_int8.from_address(id(4) + calcsize('PP')).value = 5 | |
# A little more readable | |
address = id(4) | |
offset = calcsize('PP') | |
pyint_data = c_int8.from_address(address + offset) | |
pyint_data.value = 5 |
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
from ctypes import c_int8 | |
from struct import calcsize | |
# Make 4 = 5 | |
c_int8.from_address(id(4) + calcsize('PPP')).value = 5 | |
# A little more readable | |
address = id(4) | |
offset = calcsize('PP') | |
pyint_data = c_int8.from_address(address + offset) | |
pyint_data.value = 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment