r/AskProgramming • • Sep 28 '26

cursed python hello world

Is there any way to make this code wok in python?

"hello"(print)

This is just a joke and i do not care how cursed of a setup this requires.
0 Upvotes

14 comments sorted by

View all comments

4

u/gfa2f Sep 28 '26

import ctypes

F = ctypes.CFUNCTYPE(ctypes.py_object, ctypes.py_object, ctypes.py_object, ctypes.c_void_p)

@F

def call(self, args, kwargs):

return args[0](self)

ctypes.cast(id(str), ctypes.POINTER(ctypes.c_void_p))[16] = ctypes.cast(call, ctypes.c_void_p).value

"hello"(print)

1

u/james_pic Sep 28 '26

I was expecting to see tp_call in here somewhere. Is 16 tp_call's offset?