Skip to content

Instantly share code, notes, and snippets.

@cengiz-io
Created November 19, 2014 09:33
Show Gist options
  • Save cengiz-io/c091bc441032e83089b3 to your computer and use it in GitHub Desktop.
Save cengiz-io/c091bc441032e83089b3 to your computer and use it in GitHub Desktop.
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