Hi Gustavo,

Hmm. OK, if I read that page correctly what I would need in order to emulate a python sequence, mapping, or number is the ability to register PySequenceMethods, PyMappingMethods, or PyNumberMethods then? Maybe I'll dig around in the code and see if this is difficult to add. It would certainly be useful for what I'm trying to do!

Mike.

On Jun 5, 2009, at 10:00 AM, Gustavo Carneiro wrote:

Two curious things I noted about wrapping "std::vector" myself:

1. I can't seem to get indexing access to work, even though I wrap an indexing operation with the python name "__getitem__"

2. I also can't get python's len function to work, even if I provide "__len__" as follows:
veci.add_method("size", "int", [], custom_name="__len__")

Have you been able to make either of those methods work?

It won't work because those are special methods in C/C++ side; Python extension types use a "slots" mechanism for this kind of thing, see http:// www. python.org/doc/2.6/c-api/typeobj.html


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to