misc/python/ctypes-trick.py

16 lines
299 B
Python
Raw Permalink Normal View History

2018-08-05 18:53:07 +02:00
#!/usr/bin/env nix-script
#!>python3
## Messing with literals
import ctypes
class A(ctypes.Structure):
_fields_ = [('ob_refcnt', ctypes.c_int64),
('ob_type', ctypes.POINTER(None)),
('ob_ival', ctypes.c_int64)]
A.from_address(id(2)).ob_ival = 0
print(2 == 0)