You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support to call C# named parameters from Python #849
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
[-]named parameters[/-][+]C# named parameters support from python[/+][-]C# named parameters support from python[/-][+]support to call C# named parameters from python[/+][-]support to call C# named parameters from python[/-][+]Support to call C# named parameters from Python[/+]filmor commentedon 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 commentedon 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)