By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,742 Members | 1,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,742 IT Pros & Developers. It's quick & easy.

terminology question - "foreign function library"

P: n/a
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"?

Thank you.

Dec 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

<mi************@yahoo.comwrote in message
news:11**********************@a3g2000cwd.googlegro ups.com...
|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"?

A library for connecting to and making use of foreign functions,
which are functions written in a foreign (to Python) language
and usually not particularly designed with Python in mind.

| Is the concept different from a "package"?
| Is the concept different from a "module"?

Ctypes is one particular module with the particular purpose given.
A module in general can be for any purpose.

Terry Jan Reedy


Dec 24 '06 #2

P: n/a
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.

Dec 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.