I have to use a c function (myAPI.readArr
) that returns a scalar,numpy.ndarray
or Py_None
on failure.
This works for a failure:
data = myAPI.readArr(arg1, arg2)
if not data:
raise Exception("Problem!")
but for valid arguments I get:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
How can I check that the call succeeded or not?
data = myAPI.readArr(arg1, arg2)
if data is None:
raise Exception("Problem!")
This answer contains more details about comparison to None