[C++-sig] exposing pointer to Python

Alexey Akimov alexey.akimov85 at gmail.com
Tue Jul 7 16:16:15 CEST 2009


Thank you, Renato

However this is still not clear how to wrap a pointer to double using that
indexing_suites. For types like vector<double> it is pretty much clear, but
what do i need to do in order to wrap just a simple poiner to double?

Also i have related question - how can i wrap an overloaded indexing
operator - []? For numerical operators there are some signatures like
.def(self+self) ,etc, but for operator [] i've never seen any such usage
signatures? Is there any way to do this?


2009/7/6 Renato Araujo <renatox at gmail.com>

> take a look at:
> http://www.boost.org/doc/libs/1_39_0/libs/python/doc/v2/indexing.html
>
> BR
>
>
> On Mon, Jul 6, 2009 at 8:07 PM, Alexey Akimov<alexey.akimov85 at gmail.com>
> wrote:
> > I have some class X that contains a variable which is a pointer to some
> > other class OtherClass (for simplicity we may imagine it can be some
> > standard c++ type - int, double, etc.):
> >
> > class X{
> >
> > public:
> >      OtherClass* variable;
> >
> > };
> >
> > my question is: how can I expose it to python such that user may access
> to
> > variable using [] operator?
> > like:
> >
> >>>> import module
> >>>> module.X[i] = i
> >
> > I've found several examples on this topic:
> > http://mail.python.org/pipermail/cplusplus-sig/2005-January/008189.html
> > http://osdir.com/ml/python.c++/2003-01/msg00042.html
> >
> > but still can not make this trick.
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Cplusplus-sig mailing list
> > Cplusplus-sig at python.org
> > http://mail.python.org/mailman/listinfo/cplusplus-sig
> >
>
>
>
> --
> Renato Araujo Oliveira Filho
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090707/11b65853/attachment.htm>


More information about the Cplusplus-sig mailing list