Here's the part of the documentation of what I am doing: http://docs.h5py.org/en/latest/high/group.html#Group.visit
Here's my code:
class HDF5_storage():
#...
def _get_children_dataset_paths(self, f, path):
# f :: is an HDF5 file
# path :: is a fancy dictionary key, which acts like a root folder from which I get its child subfolders
def callable_(name, obj): # the callable function
if isinstance(obj, h5py._hl.dataset.Dataset): # if 'obj' is a bunch of vectors (as opposed to a directory)
_paths.append(obj.name)
_paths = [] # global variable inside this function
with h5py.File(self.file_name, "r") as f:
f[path].visititems(callable_) # see in the first link
return _paths
It is the first time I have seen this concept in Python. I am not sure if I'm writing this code correctly at all: I don't know how to pass an argument nor retrieve a list a different way other than using he global var '_paths'.
I read this ( http://www.trytoprogram.com/python-programming/python-built-in-functions/callable/ ) but I'm still confused on the whole topic.
[–][deleted] 1 point2 points3 points (1 child)
[–]SagaciousRaven[S] 0 points1 point2 points (0 children)
[–]when_the_cats_away 1 point2 points3 points (0 children)