Optional parameters. Takes Docstring!(docstring), PyName!(pyname), ModuleName!(modulename), and fn_t
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.