In a python module, we want to call a C# Method, that has named optional parameters. But these are ignored.
Reason: The MethodBinder.Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, MethodInfo[] methodinfo) Method ignores the passed python keyword-arguments. But instead, it should assign them to the C# named parameters, if appropriate. Can you extend pythonnet to support named parameters?
snip
C#
public class LibWithDefault
{
public static string FuncWithDefault(int x, object b = null)
{
return $"x: {x} b: {b} ";
}
}
PR submitted for this feature. By the way, it looks like #80 is already addressed since version 2.1. I added some tests to make sure named parameters & default parameters can work together OK.
Activity
filmor commented on Apr 23, 2019
Yes, this would be a fine addition and we're very open to PRs on this subject. Related, there is #80 that could be tackled at the same time.
Added support for named arguments (pythonnet#849)
s4v4g3 commented on Sep 10, 2019
PR submitted for this feature. By the way, it looks like #80 is already addressed since version 2.1. I added some tests to make sure named parameters & default parameters can work together OK.
Feature/named arg support (#953)
Feature/named arg support (pythonnet#953)
Feature/named arg support (pythonnet#953)