Based on the PyTables documentation, it appears that the only way to define nested types is either to create a class level/static field with the nested type instance or to define the nested class in the parent class.
The problem is, a very common tree representation simply uses a Node type with child Node instances. Normally, this is not a problem for a Python class since the dynamic typing does not force me define the type of the child(ren), and at runtime, A Node instance can be added to another Node instance as a child.
PyTables on the other hand, requires that the type of the field is defined. Since a class definition in Python can't be used in a class level field initialization, the most common way of parent - child structure definition becomes unavailable. I am not sure if this is a constraint that exists at the HDF5 level though (did not check). Here is an example of the problem:
class A(IsDescription):
valstring = StringCol(250, pos=1)
child = A()# IMPOSSIBLE
class A(IsDescription):
valstring = StringCol(250, pos=1)
#the following would work, but now I can't define
#another AChild as child, so I got stuck with depth 1
class AChild(IsDescription):
valstring = StringCol(250, pos=1)
class ANewChild(IsDescription):
valstring = ....#useless
I have data that fits the type Node with Node children definition, and I can't represent it with PyTables at the moment. Is there a trick I'm missing?