[C++-sig] Re: C++ Python Scope Problems

David Abrahams dave at boost-consulting.com
Thu Nov 25 01:19:58 CET 2004


Chris Targett <xin at xlevus.net> writes:

>> I haven't looked at your archive, but I'm guessing that your problem is
>> unfixable.  In Python variables don't have their values changed, they
>> are rebound.  Try:
>> 
>>      python -c "x = 1; print(id(x)); x += 1; print(id(x))"
>> 
>> HTH,
>
> I see. But if i do:
>
> 	import libHg 	# name of C++ library
> 	foo = libHg.Test()
> 	print id(foo.var1), foo.var1
> 	foo.var1 += 1
> 	print id(foo.var1), foo.var1
>
> I get
> 	135523772 0
> 	135523760 1
>
> Which clearley shows the varible is 'rebound'

...which was exactly my point.  Not sure what you're illustrating
   here.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com




More information about the Cplusplus-sig mailing list