I\'m using h5py to access HDF5 files and store the h5py File objects in a class. But I\'m experiencing some strange behavior in attempting to reassign a closed h5py file ins
Not sure if this will help, but searching through the source code I found this (abbreviated):
class HLObject(object):
def __nonzero__(self):
register_thread()
return self.id.__nonzero__()
class Group(HLObject, _DictCompat):
...
class File(Group):
def __repr__(self):
register_thread()
if not self:
return ""
return '' % \
(os.path.basename(self.filename), self.mode,
_extras.sizestring(self.fid.get_filesize()))
Because there is no __str__
method, __repr__
is called to produce the output, and __repr__
first calls register_thread()
, then checks to see if self
is alive (better known as evaluating to True or False).
Python then searches the classes until it finds __nonzero__
(which again calls register_thread()
), then returns self.id.__nonzero__()
, which is apparently returning False.
So, you are correct in that the issue is not with the name binding (assignment), but why register_thread
and/or self.id
is bombing out on you, I do not know.