Topher,
> How do I gracefully check for a null TObject pointer in pyroot?
Use a boolean predicate, or if you want to turn it into a boolean value, use
the 'not not' trick. That is, from your example:
>>> this = tdir.Get("h400")
>>> print not not this
1
>>> that = tdir.Get("h401")
>>> print not not that
0
>>> if that:
... that.GetName()
...
>>> # <- nothing, as 'that' evaluates to False
The assertion will be removed. You are quite right that an exception would
be far more appropriate. But that'll be for a later release.
> How can I get the name (and title) of an object in a file without reading
> the whole thing into memory?
Isn't that a general ROOT question? I'll have a look into it later, but I need
to warn you that I know next to nothing of using ROOT, so I may not find an
answer.
HTH,
Wim
--
Wim.Lavrijsen@cern.ch -- WLavrijsen@lbl.gov -- www.lavrijsen.net
"Stop making excuses for your software." --first step towards quality
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET