[C++-sig] howto check for an attr from c++?

Stefan Seefeld seefeld at sympatico.ca
Fri Apr 13 15:33:30 CEST 2007

Neal Becker wrote:
> I need to check if an object has an attribute from c++.
> I'm using this low-level approach:
> (r is an object):
>     if (PyObject_HasAttrString (r.ptr(), "__len__")) {
> Nothing wrong with that, but is there something in the boost::python api to
> handle this?

boost::python does provide getattr(), setattr(), and delattr().



      ...ich hab' noch einen Koffer in Berlin...

More information about the Cplusplus-sig mailing list