Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2001-05-02 16:47:31

----- Original Message -----
From: <jjphatt_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, May 01, 2001 11:44 AM
Subject: [boost] Boost.Python: Defining python attributes using C++ get(),
set() methods?

> Howdy folks,
> Has anyone thought about supporting the use of C++ get() and set()
> methods to define Python attributes? Some other Python/C++ tools
> allow you to do this, and it's really helpful.

This is already supported.

> A C++ class representing an ideal gas in a reservoir:
> class Gas
> {
> // Get the temperature of the gas.
> double getTemperature() const;
> // Set the temperature of the gas.
> void setTemperature(double newTemperature);
> };

boost::python::class_builder<Gas> gas_class(module, "Gas");
gas_class.def(Gas::getTemperature, "__getattr__Temperature__");
gas_class.def(Gas::setTemperature, "__setattr__Temperature__");

Rainer Deyke (root_at_[hidden])
Shareware computer games           - 
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor

Boost list run by bdawes at, gregod at, cpdaniel at, john at