Embeded python : Can I create a dict from COS?
Hi, I need to use some pythonic library from cos.
To use them I need a python dict with some python object in it
Ex in python:
obj = pythonObject("value1")
dict = {object : obj ,key : "value2"}
result = pythonFunc(dict)
To do that I first tried to pass by dynamic object, to later convert them in dict from Json. But unfortunately the dynamic object doesn't accept python object inside it. And my pythonic function need to have an instance of my python object.
So I tried with the python built-in function dict() to create a python dictionary, but I'm not sure how to use it as in the python documentation I need to do dict(key1 = value1, key2 = value2).
Is it possible to create dict in COS using embeded python or if there is another way?
I would try something like this :
ClassMethod "test_dict"() { set pythonObj = ##class(%SYS.Python).Bytes("toto") set dict = ##class(%SYS.Python).Builtins().dict() do dict."__setitem__"("my_bytes", pythonObj) w !, dict."__getitem__"("my_bytes") }
Thanks it work.