pythonnet: Cannot access indexer from .NET derived class
If you create a .NET base class that has an indexer, and then create a .NET derived class, that derived class used in Python cannot access the indexer. You can access existing properties though just fine.
import clr
clr.AddReference("PythonTest")
import PythonTest
a = PythonTest.IndexerBase()
b = PythonTest.Indexer()
print("count of items from base class: %i" % a.Count)
print("count of items from derived class: %i" % b.Count)
print("printing base class value: %s" % a[1])
print("printing derived class value: %s" % b[1]) #ERROR HERE
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (10 by maintainers)
Yes, I tried to make sure I specified where the classes come from, otherwise it would be confusing 😄. The python code I specified above is the entire test using the library in the zip file.
This was brought up 2 times before but never resolved. There is mention of special syntax
.get_Item
that may be available.https://mail.python.org/pipermail/pythondotnet/2011-September/001173.html
https://mail.python.org/pipermail/pythondotnet/2016-February/001720.html
There are some tests for indexers, not sure why your case and others above are not covered.