How to convert ctypes' c_long to Python's int?

Question:

int(c_long(1)) doesn’t work.

Asked By: DSblizzard

||

Answers:

>>> ctypes.c_long(1).value
1
Answered By: John La Rooy
>>> type(ctypes.c_long(1).value)
<type 'int'>

Use the ‘value’ attribute of c_long object.


  c_long(1).value

or


  i = c_long(1)
  print i.value

Answered By: N 1.1
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.