Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
_tdirectory.pyzdoc
Go to the documentation of this file.
1/**
2\class TDirectory
3\brief \parblock \endparblock
4\htmlonly
5<div class="pyrootbox">
6\endhtmlonly
7## PyROOT
8
9From Python, it is possible to inspect the content of a TDirectory object
10as if the subdirectories and objects it contains were its attributes.
11Moreover, once a subdirectory or object is accessed for the first time,
12it is cached for later use.
13For example, assuming `d` is a TDirectory instance:
14\code{.py}
15# Access a subdirectory
16d.subdir
17
18# We can go further down in the hierarchy of directories
19d.subdir.subsubdir
20
21# Access an object (e.g. a histogram) in the directory
22d.obj
23
24# ... or in a subdirectory
25d.subdir.obj
26
27# Wrong attribute: raises AttributeError
28d.wrongAttr
29\endcode
30
31Furthermore, TDirectory implements a `WriteObject` Python method which relies
32on TDirectory::WriteObjectAny. This method is a no-op for TDirectory objects,
33but it is useful for objects of TDirectory subclasses such as TDirectoryFile
34and TFile, which inherit it. Please refer to the documentation of those classes
35for more information.
36\htmlonly
37</div>
38\endhtmlonly
39*/