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
With the following code in C#, when a Python class has getitem() defined, it will be converted to an array (System.Object[]) in managed code:
List lst = new List();
using (Py.GIL())
{
using (var scope = Py.CreateScope())
{
scope.Set("lst", lst);
string text = @"
class DBRow:
def init(self, row, col_names):
self.row = row
self.col_names = col_names
def __getitem__(self, key):
if isinstance(key, int):
return self.row[key]
if key in self.col_names:
index = self.col_names.index(key)
return self.row[index]
else:
return None
Activity
lostmsu commentedon Aug 8, 2022
Can you clarify? The bug is that
strvariable ends up beingSystem.Object[], and you expect it to bePyObject?BREAKING: disabled implicit conversion from Python objects implementi…
BREAKING: disabled implicit conversion from Python objects implementi…
Tiehong commentedon Aug 9, 2022
Yes, @lostmsu. I expect it to be PyObject. Then I can view the class members/properties in the C# world. System.Object[] does not allow me to do that.
lostmsu commentedon Sep 16, 2022
I believe this should be fixed now.