[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Color slice problem with Python 3



On Tue, Jul 7, 2009 at 9:44 AM, Campbell Barton <ideasman42@xxxxxxxxx> wrote:
You'll need to add a mapping subscript function that checks for a
PySlice object rather then an index.

       if (PySlice_Check(key)) {
               int len= RNA_property_collection_length(&self->ptr, self->prop);
               Py_ssize_t start, stop, step, slicelength;

               if (PySlice_GetIndicesEx((PySliceObject*)key, len, &start, &stop,
&step, &slicelength) < 0)
                       return NULL;

               if (slicelength <= 0) {
                       return PyList_New(0);
               }
               else if (step == 1) {
                       return existing_simple_slice(self, start, stop);
               }
               else {
                       PyErr_SetString(PyExc_TypeError, "slice steps not supported");
                       return NULL;
               }
       }



Cool.  How would I add this mapping subscript function?  Do you have a code you could point me at that does this?

cheers,