[C++-sig] hasattr in c++

Alex Mohr amohr at pixar.com
Fri Jul 18 18:07:19 CEST 2008


Gennadiy Rozental wrote:
> how do I have functionality similar to hasattr in c++ without any exception
> being throw/caught

Something like this?

bool hasattr(boost::python::object obj, std::string const &attrName) {
     return PyObject_HasAttrString(obj.ptr(), attrName.c_str());
}

Alex




More information about the Cplusplus-sig mailing list