Python.net doesn't work from python => .NET with named parameters?
up vote
1
down vote
favorite
I have a .NET 4.7.2 assembly with a class in it and a method. For example:
public class Foo
{
public void Bar(double duration, string ledPower, string gain, string exposure, string color) { }
}
I want to call it from python 2.7 using pythonnet. This works if the call is:
foo.Bar(1.2, '40', '50', '60', 'blah')
but not if it is using named parameters/kwargs:
foo.Bar(duration=1.2, ledPower='40', gain='50', exposure='60', color='blah')
The error says:
TypeError: No method matches given arguments
This all works with IronPython internally - now I want to run from the CLI using CPython. Any ideas?
c# python .net python.net
add a comment |
up vote
1
down vote
favorite
I have a .NET 4.7.2 assembly with a class in it and a method. For example:
public class Foo
{
public void Bar(double duration, string ledPower, string gain, string exposure, string color) { }
}
I want to call it from python 2.7 using pythonnet. This works if the call is:
foo.Bar(1.2, '40', '50', '60', 'blah')
but not if it is using named parameters/kwargs:
foo.Bar(duration=1.2, ledPower='40', gain='50', exposure='60', color='blah')
The error says:
TypeError: No method matches given arguments
This all works with IronPython internally - now I want to run from the CLI using CPython. Any ideas?
c# python .net python.net
Does it make a difference at all if you change the signature fromdouble
tofloat
?
– Amy
Nov 9 at 22:16
1
The code that does this appears to ignore keyword arguments entirely, as far as I can tell. It at least doesn't appear to make any effort to match the keyword arguments with the managed method parameter names. I'm no Python expert, but if the keyword args (dictionary) do not preserve the parameter order, I don't think this code will manage to match.
– Jeroen Mostert
Nov 9 at 22:43
Thanks for the pointer. I might have to see if I can make a fix to that. In the mean time, I wonder if I can add an overload that will work, perhaps a dict?
– LogicMan
Nov 12 at 16:10
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a .NET 4.7.2 assembly with a class in it and a method. For example:
public class Foo
{
public void Bar(double duration, string ledPower, string gain, string exposure, string color) { }
}
I want to call it from python 2.7 using pythonnet. This works if the call is:
foo.Bar(1.2, '40', '50', '60', 'blah')
but not if it is using named parameters/kwargs:
foo.Bar(duration=1.2, ledPower='40', gain='50', exposure='60', color='blah')
The error says:
TypeError: No method matches given arguments
This all works with IronPython internally - now I want to run from the CLI using CPython. Any ideas?
c# python .net python.net
I have a .NET 4.7.2 assembly with a class in it and a method. For example:
public class Foo
{
public void Bar(double duration, string ledPower, string gain, string exposure, string color) { }
}
I want to call it from python 2.7 using pythonnet. This works if the call is:
foo.Bar(1.2, '40', '50', '60', 'blah')
but not if it is using named parameters/kwargs:
foo.Bar(duration=1.2, ledPower='40', gain='50', exposure='60', color='blah')
The error says:
TypeError: No method matches given arguments
This all works with IronPython internally - now I want to run from the CLI using CPython. Any ideas?
c# python .net python.net
c# python .net python.net
edited Nov 11 at 0:42
denfromufa
3,15533098
3,15533098
asked Nov 9 at 22:07
LogicMan
266
266
Does it make a difference at all if you change the signature fromdouble
tofloat
?
– Amy
Nov 9 at 22:16
1
The code that does this appears to ignore keyword arguments entirely, as far as I can tell. It at least doesn't appear to make any effort to match the keyword arguments with the managed method parameter names. I'm no Python expert, but if the keyword args (dictionary) do not preserve the parameter order, I don't think this code will manage to match.
– Jeroen Mostert
Nov 9 at 22:43
Thanks for the pointer. I might have to see if I can make a fix to that. In the mean time, I wonder if I can add an overload that will work, perhaps a dict?
– LogicMan
Nov 12 at 16:10
add a comment |
Does it make a difference at all if you change the signature fromdouble
tofloat
?
– Amy
Nov 9 at 22:16
1
The code that does this appears to ignore keyword arguments entirely, as far as I can tell. It at least doesn't appear to make any effort to match the keyword arguments with the managed method parameter names. I'm no Python expert, but if the keyword args (dictionary) do not preserve the parameter order, I don't think this code will manage to match.
– Jeroen Mostert
Nov 9 at 22:43
Thanks for the pointer. I might have to see if I can make a fix to that. In the mean time, I wonder if I can add an overload that will work, perhaps a dict?
– LogicMan
Nov 12 at 16:10
Does it make a difference at all if you change the signature from
double
to float
?– Amy
Nov 9 at 22:16
Does it make a difference at all if you change the signature from
double
to float
?– Amy
Nov 9 at 22:16
1
1
The code that does this appears to ignore keyword arguments entirely, as far as I can tell. It at least doesn't appear to make any effort to match the keyword arguments with the managed method parameter names. I'm no Python expert, but if the keyword args (dictionary) do not preserve the parameter order, I don't think this code will manage to match.
– Jeroen Mostert
Nov 9 at 22:43
The code that does this appears to ignore keyword arguments entirely, as far as I can tell. It at least doesn't appear to make any effort to match the keyword arguments with the managed method parameter names. I'm no Python expert, but if the keyword args (dictionary) do not preserve the parameter order, I don't think this code will manage to match.
– Jeroen Mostert
Nov 9 at 22:43
Thanks for the pointer. I might have to see if I can make a fix to that. In the mean time, I wonder if I can add an overload that will work, perhaps a dict?
– LogicMan
Nov 12 at 16:10
Thanks for the pointer. I might have to see if I can make a fix to that. In the mean time, I wonder if I can add an overload that will work, perhaps a dict?
– LogicMan
Nov 12 at 16:10
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233874%2fpython-net-doesnt-work-from-python-net-with-named-parameters%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does it make a difference at all if you change the signature from
double
tofloat
?– Amy
Nov 9 at 22:16
1
The code that does this appears to ignore keyword arguments entirely, as far as I can tell. It at least doesn't appear to make any effort to match the keyword arguments with the managed method parameter names. I'm no Python expert, but if the keyword args (dictionary) do not preserve the parameter order, I don't think this code will manage to match.
– Jeroen Mostert
Nov 9 at 22:43
Thanks for the pointer. I might have to see if I can make a fix to that. In the mean time, I wonder if I can add an overload that will work, perhaps a dict?
– LogicMan
Nov 12 at 16:10