Reputation: 41
How do I create a dictionary of string, object in Python using Python NET?
C#
d = new Dictionary<string,object>() // works
Python
Dictionary [string, object] # TypeError : type(s) expected
Upvotes: 3
Views: 2726
Reputation: 1646
You can create it like that:
import clr
from System.Collections.Generic import Dictionary
from System import String
from System import Object
d = Dictionary[String, Object]()
d['Entry 1'] = 'test'
d['Entry 2'] = 12.3
d.Count # returns 2
Upvotes: 2