does this do the job:if not hasattr(tree, 'branch_name'): raise RuntimeError('bla')or even:tree.branch_namewhich will raise an AttributeError on non-existence?
I’ll have a look to see why the value isn’t set in the array.
so I don’t observe the same thing as you have, and I don’t notice any difference in behavior between C++ and python. In fact, the code is straightforward (from TTree): if (!nb && !foundInFriend) {
if (found==0) Error("SetBranchStatus", "unknown branch -> %s", bname);
return;
}
if (found) *found = nb + foundInFriend;
So the value of “found” is not touched unless some branch is found (i.e. you can’t rely on it being 0 either, unless you input a 0, so be careful using this in a loop). Arguably, the interface would be nicer (I think) if the code set *found = 0 in case of failure. Of course, it most certainly can not and set it to 1 and report the error.