[C++-sig] Disallow adding attributes to wrapped classes from Python
Stefan Haller
haller at ableton.com
Mon Dec 13 10:27:54 CET 2004
Is there a way to make the __dict__ of exposed classes read-only? I
fear it will be a common error for Python programmers to make typos when
setting attributes, and I would like this to generate an error rather
than silently adding a new attribute.
class_<Foo>("Foo")
.add_property("foobar", &Foo::getFooBar, &Foo::setFooBar)
;
>>> foo.foobaz = 7 # oops: typo!
>>> foo.foobaz
7
--
Stefan Haller
Ableton
http://www.ableton.com/
More information about the Cplusplus-sig
mailing list