StringSlice returns this object as a string slice.
()
| 287 | |
| 288 | // StringSlice returns this object as a string slice. |
| 289 | func (ob *PyObject) StringSlice() []string { |
| 290 | if ob.rawptr == nil { |
| 291 | return []string{} |
| 292 | } |
| 293 | l := int(C.PyList_Size(ob.asRaw())) |
| 294 | if l < 0 { |
| 295 | return nil |
| 296 | } |
| 297 | s := make([]string, l) |
| 298 | for i := 0; i < l; i++ { |
| 299 | item := C.PyList_GetItem(ob.asRaw(), C.longlong(i)) |
| 300 | if item == nil { |
| 301 | continue |
| 302 | } |
| 303 | isUnicode := bool(C.Py_IsUnicode(item)) |
| 304 | if !isUnicode { |
| 305 | continue |
| 306 | } |
| 307 | s[i] = fromRawOb(item).String() |
| 308 | } |
| 309 | return s |
| 310 | } |
| 311 | |
| 312 | // Uint32 returns an uint32 integer from the raw Python object. |
| 313 | func (ob *PyObject) Uint32() uint32 { |