[C++-sig] [boost.python] __dict__ question
David Abrahams
dave at boostpro.com
Fri Oct 10 20:24:07 CEST 2008
on Thu Oct 09 2008, Robert <rcdailey-AT-gmail.com> wrote:
> Hi,
>
> Is it really necessary to obtain __dict__ in order to add variables to
> some object's scope?
No.
> For example, suppose I want to define a global
> variable in a module, how would I do this? I know the first step I
> must take is to import the module:
>
> boost::python::import( "my_module" )
>
> What then? A pseudo-code example of what I would expect is something like:
>
> using namespace boost::python;
> import( "my_module" ).attr( "my_global" ) = object( 5.0f );
Looks OK to me. In fact,
import( "my_module" ).attr( "my_global" ) = 5.0f;
should work.
--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
More information about the Cplusplus-sig
mailing list