Is there a way in python to create a data container with numeric field names?
A minimal example: I have variables called beta0
, beta1
, beta2
and would like to pack them into a container beta
and access them by beta.0
, beta.1
, beta.2
.
I checked recordclass
, namedtuple
, and dataclass
, but none of them allows this.
EDIT: What is the best practice in python for treating a bunch of related parametres?
you could simply use a dictionary and access them.
Access them with
If you need to use the numeric value as variable you can also do this by indexing: eg.