Created
November 19, 2014 09:33
-
-
Save cengiz-io/c091bc441032e83089b3 to your computer and use it in GitHub Desktop.
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 | |
class IntStruct(ctypes.Structure): | |
_fields_ = [("ob_refcnt", ctypes.c_long), | |
("ob_type", ctypes.c_void_p), | |
("ob_size", ctypes.c_ulong), | |
("ob_digit", ctypes.c_long)] | |
def __repr__(self): | |
return ("IntStruct(ob_digit={self.ob_digit}, " | |
"refcount={self.ob_refcnt})").format(self=self) | |
id_113 = id(113) | |
i_ptr = IntStruct.from_address(id_113) | |
i_ptr.ob_digit = 4 | |
print ("113 == 4 ? {}".format(113 == 4)) | |
print ("112 + 1 = {}".format(112 + 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment