[Python-3000] adding gamma and error functions to math module

Mark Dickinson dickinsm at gmail.com
Wed Jul 16 19:35:47 CEST 2008


On Wed, Jul 16, 2008 at 5:03 PM, nirinA raseliarison
<nirina at mail.blueline.mg> wrote:
> my initial motivation is to make these functions accessible,
> with just a few lines of additionnal code. that's so simple
> with a linux box!

As Daniel Stutzbach already hinted, the easiest way to just get at the
system gamma and error functions, in a platform-dependent manner,
is probably to use ctypes.  On OS X:

Macintosh-3:trunk dickinsm$ ./python.exe
Python 2.6b1+ (trunk:65004M, Jul 16 2008, 10:17:30)
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> tgamma = ctypes.CDLL('libm.dylib').tgamma
>>> tgamma.restype = ctypes.c_double
>>> tgamma.argtypes = [ctypes.c_double]
>>> tgamma(1.0)
1.0
>>> tgamma(6.1)
142.45194406567867

Is this enough for your immediate needs?

Mark


More information about the Python-3000 mailing list