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 *
classMY_STRUCTURE(ctypes.Structure):
def__init__(self):
self.member1 = 1
self.member2 = 2super().__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"