From sumit at sans.com Tue Mar 11 17:47:16 2014 From: sumit at sans.com (Sumit) Date: Tue, 11 Mar 2014 16:47:16 -0000 Subject: [capi-sig] Fulltime/Permanent Job :: Python Expert :: NY - 10003 Message-ID: <004301cf3d47$b1791ab0$146b5010$@com> Hi, Please let me know your interest and availability for the below Fulltime/Permanent Job Opening. NOTE: If You are interested, Please furnished below details in the matrix and a copy of your Resume so that we can submit your profile. Position: Python Expert Location: NY - 10003 Duration: Fulltime/Permanent Skills/Experience . Build data service backends using the Flask and Django web-application frameworks . Work with Product Managers, Designers and Front-End Engineers who specify, design and build products and widgets that consume your data services. . Communicate and collaborate well . Are a seasoned Python expert . Have designed and implemented distributed HTTP data services . Have extensive SQL experience . Have worked with GIT. . Are experienced working with and managing a UNIX system NOTE: If You are interested, Please furnished below details in the matrix and a copy of your Resume so that we can submit your profile. . Full Name Email ID (Please try to share two emails) Contact Number Alternate Contact Number Current Location ( street Address with Zip Code) Work Authorization (US/GC/EAD/H1B) Expiry Date of Visa (if applicable) Expected Salary Availability to Start Project Interview Availability Can you do Face to Face round Are you open to Background Check Best time to reach Would you prefer to Relocate/Commute Reference #1 Reference #2 Thanks & Regards Sumit Kumar SANS Consulting Services, Inc. 646-688-4787 Sumit at sans.com From sagar.masuti at gmail.com Sat Mar 22 17:50:24 2014 From: sagar.masuti at gmail.com (sagar masuti) Date: Sun, 23 Mar 2014 00:50:24 +0800 Subject: [capi-sig] (no subject) Message-ID: Is it possible to cast an int to a class type ? I have the following code in c: #include "Python.h" #define PYTHON_FILENAME "modelparam" void getmodelparam(int pModelParam) ; typedef struct { int seconds; int nanoseconds; } someTime; int main () { someTime *pSome ; int a ; printf ("Testing the python interfaces\n") ; pSome = (someTime *) calloc(1, sizeof(someTime)) ; pSome->seconds = 10 ; pSome->nanoseconds = 20 ; a = (int) pSome ; printf ("a is %d, pSome is %d\n", a, pSome) ; getmodelparam(a) ; printf ("After the python call values are : %d, %d\n",pSome->seconds, pSome->nanoseconds) ; return 0 ; } void getmodelparam(int pModelParam) { PyObject *pName ; PyObject *pModule ; PyObject *pDict ; PyObject *pFunc ; int iSize = 0 ; char pcFunctionName[] = "modifymodelparam" ; double dTemp1, dTemp2 ; /* Initialize the python interpreter */ Py_Initialize() ; /* Get Python code/module */ pName = PyUnicode_FromString(PYTHON_FILENAME); if (NULL != pName) { /* Import the module equivalent to doing 'import calresidual' in python */ pModule = PyImport_Import(pName); Py_DECREF(pName) ; if (NULL != pModule) { /* Get the function and check if its callable function */ pFunc = PyObject_GetAttrString(pModule, pcFunctionName); if (pFunc && PyCallable_Check(pFunc)) { /* Build the input arguments */ PyObject *pResult = PyObject_CallFunction(pFunc,"i", pModelParam) ; } else { printf ("Some error with the function\n") ; } } else { printf ("Couldnt load the module %s\n", PYTHON_FILENAME) ; } } else { printf ("Couldnt convert the name of the module to python name\n") ; } /* Release the resources. */ Py_DECREF(pModule) ; Py_DECREF(pFunc) ; Py_DECREF(pName) ; /*Release the interpreter */ Py_Finalize() ; } And in python modelparam.py i have : import ctypes class someTime(ctypes.Structure): _fields_ = [("seconds", ctypes.c_uint), ("nanoseconds", ctypes.c_uint)] def modifymodelparam(m): # Not sure how to access internal elements using m ?? # How to typecast m ?? n = someTime(m) print ('Seconds', n.seconds) How can I typecast the address passed from C to a class type in python so that i can access those class parameters or indirectly saying accessing the structure parameters?