[C++-sig] Re: Exporting STL List to Python
by Mike Rovner other posts by this author
Oct 23 2003 5:24PM messages near this date
[C++-sig] Re: Pickling object from nested class
|
[C++-sig] Exporting STL List to Python
Andrew Ellem wrote:
> > I'm trying to export a STL list to Python, but I'm having problems
> > when the list type is a pointer. So, list<int> works, but list<int
> > *> causes the error:
> > TypeError: No to_python (by-value) converter found for C++ type: int*
Pointer is a foreign concept for Python, so you need help the BPL a little
bit.
Numbers in Python are immutable, unlike the int*, so bpl doesn't know enough
about your intents.
> > Is there something special I have to do with pointers?
Yes. Generally you have to specify return_value_policy when returning a
pointer
to tell bpl how to handle it. See docs about it.
Answer the questions:
- who manages the memory,
- is that pointer an lvalue,
- how pointers shall be (if ever) copyed
to start with.
Try create your own type
struct IntP { int* pi; };
wrap it and see what happened.
HTH,
Mike
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
|