Python 如何从';家长';指针(元)类?
假设如下:Python 如何从';家长';指针(元)类?,python,python-3.x,ctypes,Python,Python 3.x,Ctypes,假设如下: import ctypes class Point(ctypes.Structure): _fields_ = [ ('x', ctypes.c_double), ('y', ctypes.c_double) ] def some_routine(struct_pointer): # Do something to get '_fields_' from structure behind struct_pointer
import ctypes
class Point(ctypes.Structure):
_fields_ = [
('x', ctypes.c_double),
('y', ctypes.c_double)
]
def some_routine(struct_pointer):
# Do something to get '_fields_' from structure behind struct_pointer
print(_fields_)
some_routine(ctypes.POINTER(Point))
在我的场景中,
类点
和一些例程
都隐藏在不同的模块中。因此,我没有找到一种从某些例程
中检索类点
字段定义的方法。如何做到这一点?您可以使用stuct\u指针。\u type\u
引用点
类。\u type\u
正是我想要的-谢谢!您是如何在不同的模块中使用type打印Point的元素的?