I found a way: using %immutable command. It's in the documentation.

Le 2013-03-28 à 11:08, Olivier Voyer <olivier.voyer@gmail.com> a écrit :

Hi Bjoern,

Thank you for your answer. This is a good suggestion, but I think it is more user-friendly to have properties rather than getters... this is why I was wondering if this was possible with SWIG.

On Thu, Mar 28, 2013 at 10:51 AM, Björn Simon <simon@altair.com> wrote:

Hi Oliver,


Why not having the member variables as private/protected and provide getter/setter for Username and only getter for Password?

So using DataSource more as a class than as a struct.






From: Olivier Voyer [mailto:olivier.voyer@gmail.com]
Sent: Thursday, March 28, 2013 10:47 AM
To: swig-user@lists.sourceforge.net
Subject: [Swig-user] Read-only property in C++


I'm wrapping C++ to Python using SWIG. How can I tell SWIG that a property is read-only?


class DataSource






            std::string Username

            std::string Password; // Read-only?