[C++-sig] Wrapping global data

Matthew Scouten matthew.scouten at gmail.com
Tue Oct 2 22:20:45 CEST 2007


On 10/2/07, Roman Yakovenko <roman.yakovenko at gmail.com> wrote:
> On 10/2/07, Matthew Scouten <matthew.scouten at gmail.com> wrote:
> > OK, I can wrap a global function, I can wrap a member function, I can
> > wrap a member variable,
>
> The answer is: it depends
> * on global variable type
> * whether you need to share it between Python and C++ code at the same time
>
> for immutable types:
> http://boost.org/libs/python/doc/v2/scope.html
>
> for shared class instances:
> http://wiki.python.org/moin/boost.python/HowTo#head-85904d74f4f9f20c1380ede50e2eb95a4c333c37
>
>  P.S. Google will point you to other resources
>

Ah. From
http://mail.python.org/pipermail/c++-sig/2003-June/004240.html
it looks like what I thought I wanted to do is not possible. What I
actually need to do is create a function that returns that variable in
question. I would have thought that exposing a global variable
directly would be a fairly obvious thing to do. Is there a reason that
it is not possible?



More information about the Cplusplus-sig mailing list