[Python.NET] TypeError: unindexable object

Rog F r_foskett at hotmail.com
Thu Feb 18 14:10:21 EST 2016


Hello,


I'm trying to set an object property based on an indexer as described in the C# example here: https://msdn.microsoft.com/en-us/library/hh964567.aspx, but both examples fail with "TypeError: unindexable object"


Python code looks like this:


criteria = ManagementPackClassCriteria("Name = 'Microsoft.Windows.Computer'")
classes  = mg.EntityTypes.GetClasses(criteria)
CIClass  = classes[0]
instance = CreatableEnterpriseManagementObject(mg, CIClass)
print "instance: "+str(instance) # this isnt None
mprop    = CIClass["PrincipalName"]
instance[mprop].Value = "foo"


C# .NET equivalent would be something like this:

ManagementPackClass CIClass = mp.GetClass("Microsoft.Windows.Computer");
ManagementPackProperty mprop = CIClass["PrincipalName"];
instance[mprop].Value = "foo";


Error appears to be thrown in pythonnet classobject.cs (https://github.com/pythonnet/pythonnet/blob/master/src/runtime/classobject.cs#L174)


Are there any back doors through pythonnet/System.Runtime.something that i can use to get around this?  Works fine with IronPython, however i cant package up & use AWS boto3 library with IronPython which i also need (but can with py2exe + pythonnet) - so ideally want to use pythonnet.


Thanks!


Roger




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20160218/ad20b50f/attachment.html>


More information about the PythonDotNet mailing list