Home > OS >  Pythonnet (clr) and C# lists and enums
Pythonnet (clr) and C# lists and enums

Time:04-03

I have myClass which contains a field myList which is a list of elements from myEnum. I would like to add to this list more elements but in python. However exec(f"myClass.myList.Add(myEnum.{e}))" doesnt work because myClass.myList in Python is a list of integers. What can I do? I want to add elements by its name, not its int position.

CodePudding user response:

Switch to pythonnet 3.0 previews. In 3.0 .NET lists are not converted to Python lists, instead they just behave like Python lists when seen from Python.

  • Related