Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

ctypes

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

like image 803
DSblizzard Avatar asked Feb 24 '10 23:02

DSblizzard


2 Answers

>>> ctypes.c_long(1).value 1 
like image 57
John La Rooy Avatar answered Sep 20 '22 15:09

John La Rooy


Use the 'value' attribute of c_long object.

    c_long(1).value  

or

    i = c_long(1)   print i.value  
like image 32
N 1.1 Avatar answered Sep 19 '22 15:09

N 1.1