Movatterモバイル変換


[0]ホーム

URL:


Navigation

Slice Objects

PyTypeObjectPySlice_Type

The type object for slice objects. This is the same asslice andtypes.SliceType.

intPySlice_Check(PyObject *ob)
Return true ifob is a slice object;ob must not beNULL.
PyObject*PySlice_New(PyObject *start,PyObject *stop,PyObject *step)
Return value: New reference.

Return a new slice object with the given values. Thestart,stop, andstep parameters are used as the values of the slice object attributes of thesame names. Any of the values may beNULL, in which case theNone will beused for the corresponding attribute. ReturnNULL if the new object could notbe allocated.

intPySlice_GetIndices(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)

Retrieve the start, stop and step indices from the slice objectslice,assuming a sequence of lengthlength. Treats indices greater thanlength aserrors.

Returns 0 on success and -1 on error with no exception set (unless one of theindices was notNone and failed to be converted to an integer, in whichcase -1 is returned with an exception set).

You probably do not want to use this function. If you want to use slice objectsin versions of Python prior to 2.3, you would probably do well to incorporatethe source ofPySlice_GetIndicesEx, suitably renamed, in the source ofyour extension.

intPySlice_GetIndicesEx(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, Py_ssize_t *slicelength)

Usable replacement forPySlice_GetIndices. Retrieve the start, stop,and step indices from the slice objectslice assuming a sequence of lengthlength, and store the length of the slice inslicelength. Out of boundsindices are clipped in a manner consistent with the handling of normal slices.

Returns 0 on success and -1 on error with exception set.

New in version 2.3.

Previous topic

Descriptor Objects

Next topic

Weak Reference Objects

This Page

Quick search

Navigation

©Copyright 1990-2008, Python Software Foundation. Last updated on Oct 02, 2008. Created usingSphinx 0.5.

[8]ページ先頭

©2009-2026 Movatter.jp