After introducing Python classes, Python objects now have specific types instead of all being *py.Object. For example, we can create a Dog instance through the constructor:
type Dog struct {
py.Object
}
dog := NewDog(py.Str("dahuang"))
However, the obtained Python object can only call struct methods and cannot be passed as a parameter to functions or methods, which is obviously inconsistent with Python syntax.
Python demo:
LLGo Binding:
//go:linkname Say py.say
func Say(dog *py.Object) *py.Object
LLGo use:
Fault:
cannot use dog (variable of type *Dog) as *py.Object value in argument
After introducing Python classes, Python objects now have specific types instead of all being
*py.Object. For example, we can create aDoginstance through the constructor:However, the obtained Python object can only call struct methods and cannot be passed as a parameter to functions or methods, which is obviously inconsistent with Python syntax.
Python demo:
LLGo Binding:
LLGo use:
Fault: