Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
_tdirectoryfile.pyzdoc
Go to the documentation of this file.
1/**
2\class TDirectoryFile
3\brief \parblock \endparblock
4\htmlonly
5<div class="pyrootbox">
6\endhtmlonly
7## PyROOT
8
9In the same way as for TDirectory, it is possible to inspect the content of a
10TDirectoryFile object from Python as if the subdirectories and objects it
11contains were its attributes. For more information, please refer to the
12TDirectory documentation.
13
14In addition to the attribute syntax, one can inspect a TDirectoryFile in Python
15via the `Get` method. In this case, the subdirectory/object name is specified
16as a string:
17\code{.py}
18# Access a subdirectory
19d.Get('subdir')
20
21# We can go further down in the hierarchy of directories
22d.Get('subdir/subsubdir')
23
24# Access an object (e.g. a histogram) in the directory
25d.Get('obj')
26
27# ... or in a subdirectory
28d.Get('subdir/obj')
29
30# Wrong attribute: returns null
31x = d.Get('wrongAttr') # x points to null
32\endcode
33
34Furthermore, TDirectoryFile inherits a `WriteObject` Python method from
35TDirectory. Such method allows to write an object into a TDirectoryFile
36with the following syntax:
37\code{.py}
38# Write object obj with identifier 'keyName'
39d.WriteObject(obj, 'keyName')
40\endcode
41\htmlonly
42</div>
43\endhtmlonly
44*/