The function to wrap.
Optional parameters. Takes Docstring!(docstring), PyName!(pyname), ModuleName!(modulename), and fn_t modulename: The name of the python module in which the wrapped function resides. pyname: The name of the function as it will appear in Python.
The function type of the function to wrap. This must be specified if more than one function shares the same name, otherwise the first one defined lexically will be used. docstring: The function's docstring.
import pyd.pyd; string foo(int i) { if (i > 10) { return "It's greater than 10!"; } else { return "It's less than 10!"; } } extern (C) export void inittestdll() { def!(foo, ModuleName!"testdll"); add_module("testdll"); }
And in Python:
>>> import testdll >>> print testdll.foo(20) It greater than 10!
Wraps a D function, making it callable from Python.
Supports default arguments, typesafe variadic arguments, and python's keyword arguments.