Menu

#7 Add Object::as_bool for Python2/Objects.hxx

None
closed
nobody
None
5
2016-07-08
2016-07-08
Ben Webb
No

Please add the following code to the class Object in Python2/Objects.hxx

    // convert to bool
    bool as_bool() const
    {
        return PyObject_IsTrue( ptr() ) != 0;
    }

This will allow the same code to be used to support either version (2 or 3) of python

Discussion

  • Barry Alan Scott

    Not sure what was going on in 2008 but there are two functions to do the same test.
    as_bool() and isTrue(). You could use isTrue until I release a new PyCXX.

    commited as r347

     
  • Barry Alan Scott

    • status: open --> closed
    • Group: -->
     

Log in to post a comment.