mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
py::class_<T>'s `def_property` and `def_property_static` can now take a `nullptr` as the getter to allow a write-only property to be established (mirroring Python's `property()` built-in when `None` is given for the getter). This also updates properties to use the new nullptr constructor internally.
This commit is contained in:
committed by
Jason Rhinelander
parent
71178922fd
commit
0a0758ce3a
@@ -155,6 +155,9 @@ the setter and getter functions:
|
||||
.def_property("name", &Pet::getName, &Pet::setName)
|
||||
// ... remainder ...
|
||||
|
||||
Write only properties can be defined by passing ``nullptr`` as the
|
||||
input for the read function.
|
||||
|
||||
.. seealso::
|
||||
|
||||
Similar functions :func:`class_::def_readwrite_static`,
|
||||
|
||||
Reference in New Issue
Block a user