I have created a custom Python class, for use in dataclasses, that accepts python lists, but internally stores them as a C++ vector (interfaced with CERN ROOT). The type of what is stored in the vector is specified as a string during init. Therefore, this type is not exposed as a type of the instance, and I would like it to be. I wonder if you could give me some clues? The init part of the class looks like that:
class StdVectorList(MutableSequence):
"""A python list interface to ROOT's std::vector"""
#vec_type = ""
def __init__(self, vec_type, value=[]):
"""
Args:
vec_type: C++ type for the std::vector (eg. "float", "string", etc.)
value: list with which to init the vector
"""
self._vector = ROOT.vector(vec_type)(value)
#: C++ type for the std::vector (eg. "float", "string", etc.)
self.vec_type = vec_type
And the class is used, for example, like:
a = StdVectorList("float")
I would like to ensure with typehints, that the user gives for example, StdVectorList("float") not StdVectorList("int").