Optional parameters. Takes Docstring!(docstring), PyName!(pyname), ModuleName!(modulename), and fn_t
1 import pyd.pyd; 2 string foo(int i) { 3 if (i > 10) { 4 return "It's greater than 10!"; 5 } else { 6 return "It's less than 10!"; 7 } 8 } 9 extern (C) 10 export void inittestdll() { 11 def!(foo, ModuleName!"testdll"); 12 add_module("testdll"); 13 }
And in Python: $(D_CODE >>> import testdll >>> print testdll.foo(20) It's greater than 10!)
Wraps a D function, making it callable from Python.
Supports default arguments, typesafe variadic arguments, and python's keyword arguments.