Call calls a callable Python object with arguments given by the tuple args. If no arguments are needed, then args may be NULL. Returns the result of the call on success, or a null reference on failure.
(args ...*PyObject)
| 364 | // Call calls a callable Python object with arguments given by the tuple args. If no arguments are needed, then args |
| 365 | // may be NULL. Returns the result of the call on success, or a null reference on failure. |
| 366 | func (ob *PyObject) Call(args ...*PyObject) *PyObject { |
| 367 | if ob.rawptr == nil { |
| 368 | return nil |
| 369 | } |
| 370 | if len(args) == 0 { |
| 371 | return &PyObject{rawptr: C.PyObject_CallObject(ob.rawptr, nil)} |
| 372 | } |
| 373 | tuple := NewTuple(len(args)) |
| 374 | for pos, arg := range args { |
| 375 | tuple.Set(pos, arg) |
| 376 | } |
| 377 | defer tuple.DecRef() |
| 378 | r := C.PyObject_CallObject(ob.rawptr, tuple.rawptr) |
| 379 | return &PyObject{rawptr: r} |
| 380 | } |