Python - 子类可以使用其基类中的属性吗?

时间:2014-03-01 11:56:15

标签: python structure ctypes derived-class

现在我用Python了:

import ctypes

class base:
    hello = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_int)

    class sub(ctypes.Structure):
        _fields_ = [('example', ctypes.c_int),
                    ('hello', hello)]           # Here I would like to use the
                                                # "hello"-attribute from the base class

由于sub - 类派生自ctypes.Structure,我不确定如何从base - 类派生它。 这样的话甚至是可能的,还是我需要在ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_int) - 类中使用hello代替sub

当然我愿意接受其他建议!

0 个答案:

没有答案