I need run a c++ method from my python program
but the c++ method need a few parameters
what need for call that method in my python code with the paramethers

Here is a code example ...

# using the module ctypes you can access DLLs written in C/C++
# ctypes converts between Python types and C types
# there are two ways to write DLLs:
# most common uses cdecl, import with cdll
# Win and VB may use stdcall, import with windll
# module ctypes is built into Python25 and higher
# look under ctypes in the Python manual

from ctypes import *

# as an example let's use msvcrt.dll
# this is the MS C library containing many standard C functions
# import the C function strchr() from msvcrt.dll
strchr = cdll.msvcrt.strchr

# declare the return type ...
# a 'pointer to a string' (which then converts to a Python string)
strchr.restype = c_char_p

# these are the argument types ...
# Python string converts to 'pointer to a string' --> c_char_p
# Python single char string converts to C char --> c_char
strchr.argtypes = [c_char_p, c_char]

# now call the function and show the result
print strchr('abcdefg', 'd')  # result --> defg

# some C functions are easier to access ...
printf = cdll.msvcrt.printf
printf("Hello, %s\n", "World!")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.