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

Gennadiy Rozental rogeeff at gmail.com
Sun Jul 20 20:44:18 CEST 2008


Alex Mohr <amohr <at> pixar.com> writes:

> 
> 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());
> }

Thanks, this seems to work.

Gennadiy




More information about the Cplusplus-sig mailing list