I am currently reading lines from a .csv file and storing the data in a list of array.array('f') objects. Since I will be passing the individual lines to different processes I would like to store an (line) id with every array.array object.
I know I can do this obviously by defining a new class and encapsulating the data, but I was wondering if there is a different way by adding dynamically a custom attribute to array.array. The benefit would be not having an additional look up when accessing the data itself and not having to define a class with just the id and the data.
I know a list of tuples are an option too, but in the near future I will want to store mutable attributes.
What is the python way to do this?
array.arrayobjects don't allow for arbitrary attributes, no. Encapsulation is your only option there.