[C++-sig] Static, again...

David Abrahams dave at boost-consulting.com
Wed Nov 13 14:19:53 CET 2002

Hugo van der Merwe <hugo at adept.co.za> writes:

> On Wed, Nov 13, 2002 at 08:51:12AM +0200, Hugo van der Merwe wrote:
>> Do properties currently only handle straight forward single parameter
>> "setters"? How difficult would it be to allow it to do two parameters,
>> with e.g. "object.property[5] = 10"? (Or can it do that already?)
> I just saw this in another email:
>> > It seems natural to expose class Heavy with 3 attributes: x,y and z which
>> > will behave like dictionaries.
>> > How to do that?
>> Use the add_property member of class_<>:
>>    http://www.boost.org/libs/python/doc/v2/class.html#class_-spec-modifiers
> Cool, I'll try testing it later. Is there a way to expose a 3
> parameter "setter" (which can then be addressed like a matrix)? I'd
> think this is asking a bit too much, at this point one should probably
> just stick with "Get(x,y)" and "Set(x,y,value)" methods.

Yes, but I'll leave it as an "exercise for the reader". Properties are
a Python 2.2 thing, not a Boost.Python feature. Try it in pure
Python. If you can get that to work, you can probably get it to work
in Boost.Python. Hint: you'll need a proxy class.

                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

More information about the Cplusplus-sig mailing list