Skip to content Skip to sidebar Skip to footer

Ctypes Structure AutoComplete

How is that possible for Python IDE(any) Intellisense to discover structure members in design time? class MY_STRUCTURE(ctypes.Structure): _fields_ = [('member1', c_int)

Solution 1:

I understand from @Alfe response that this depends on the IDE. Python IDLE find the members of the structure in design time. PyCharm cannot.

I use my structure with following way, and looks working fine. By this way ctypes.structure can also be expanded with python class features.

import ctypes
from ctypes import *

    class MY_STRUCTURE(ctypes.Structure):
        def __init__(self):
            self.member1 = 1
            self.member2 = 2
            super().__init__(member1=self.member1,
                         member2=self.member2)

        _fields_ = [("member1", c_int),
                    ("member2", c_int)]

The key here is to call super() base class.


Post a Comment for "Ctypes Structure AutoComplete"