I'm new to Python from a Java background and I'm trying to construct DTOs to wrap my data as I would with Java Collections framework by extending a collection.
public class MyDto<T> extends ArrayList<T> implements MyDtoInterface<T> { ... }
I've read python-quick-and-dirty-datatypes-dto and it seems to provide a basis for what I need. However what I cannot figure from the accepted answers is how to make my dto a type rather than a wrapper. The accepted answer is a python script rather than a class. I want to avoid having to do this:
class NamedDto(namedtuple):
data = namedtuple("first", "second", "etc")
dto = NamedDto()
dto.data.first = 1
dto.data.second = 2
dto.data.etc = None
print(dto)
and instead do this:
dto = NamedDto()
dto.first = 1
dto.second = 2
dto.etc = None
and/or
dto = NamedDto(1,2,3)
print(dto.first)
print(dto.second)
print(dto.etc)
I've also read, which don't seem to answer this specific question.