embedding python: simulating sequence get item / set item methods

Johannes Zellner johannes at zellner.org
Tue Jan 17 01:42:20 CET 2006


when embedding python: how can I create a type which simulates item
getters and setters? Something like this:

void setter(PyObject* self, int i, PyObject new_value)
    // do something

PyObject* getter(PyObject* self, int i)
    // do something
    return something;

and I'd like the first method called if (from a python script):

    my_list[i] = value

and the second method, if accessing the list

    print str(my_list[i])

Is this possible?


More information about the Python-list mailing list