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
What commands did you run to trigger this issue? If you can provide a
[Minimal, Complete, and Verifiable example] (http://stackoverflow.com/help/mcve)
this will help us understand the issue.
`
dynamic sys = Py.Import("sys");
dynamic path2 = sys.path;
foreach (PyObject item in path2)
{
Console.WriteLine(item);
}
`
If there was a crash, please include the traceback here.
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: "Cannot implicitly convert type 'Python.Runtime.PyObject' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)"
changed the title [-]Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: "Cannot implicitly convert type 'Python.Runtime.PyObject' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)"[/-][+]`foreach` over dynamic `PyObject`[/+]on Jan 25, 2022
I have to add tho, that the 1.) approach works good! (item in new PyTuple(path2))
The 2.) approach fails aswell, with the same exception as in this thread! (PyIter.GetIter(path2))
Activity
lostmsu commentedon Jan 25, 2022
As a workaround you can do
item in new PyTuple(path2), oritem in PyIter.GetIter(path2).[-]Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: "Cannot implicitly convert type 'Python.Runtime.PyObject' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)"[/-][+]`foreach` over dynamic `PyObject`[/+]CodingMadness commentedon Jan 25, 2022
@lostmsu
thx for the quick response :)
I have to add tho, that the 1.) approach works good! (item in new PyTuple(path2))
The 2.) approach fails aswell, with the same exception as in this thread! (PyIter.GetIter(path2))
allow dynamic PyObject conversion to IEnumerable when the object is a…
allow dynamic PyObject conversion to IEnumerable when the object is a…