mi************@yahoo.com wrote:
I am prompted to make these inquiries after seeing the following link
to ctypes:
http://docs.python.org/lib/module-ctypes.html
in which ctypes is described as a foreign function library.
What is the definition of "foreign function library"?
Is the concept different from a "package"?
Is the concept different from a "module"?
Neither. If you have a library, completely unrelated to Python, but you
would like to make calls into it from Python, there are several ways to
proceed.
(A good example of such a library is the OpenGL library:
C:/WINDOWS/SYSTEM32/opengl32.dll.)
You can craft an extension to Python, written in C perhaps and linked to
the DLL in question, that provides functions which can be called from
Python and which make the appropriate calls into the DLL. (Several
products help with building of such an extension module, SWIG being the
one I've used.)
A newer alternative to building such extensions is ctypes. If you can
discern (from the documentation) the exact calling parameters footprint
to a function in a DLL, then ctypes can directly call that function with
your parameters. This is done directly in Python and ctypes without the
need for building any extension module.
Gary Herron
Thank you.