go-python3 How to instantiate a python class #26
Replies: 1 comment
-
one way would be to just write some Python code to instantiate the class and run it with PyRun_SimpleString. You can then use Python C-API functions to find the resulting PyObject in the root dict. Once you have it mapped to a Go variable you can i.e. read attributes or call methods. Most of this is outlined in this example. Your instantiated Python class is just a PyObject. https://github.com/christian-korneck/python-go/tree/master/py-bindings/outliers Another way: To instantiate a Python class the pure C-API way, this might help: |
Beta Was this translation helpful? Give feedback.
-
I don't know how to use go-python3 for class initialization
Beta Was this translation helpful? Give feedback.
All reactions