I have a list of objects belonging to the class Config defined as the following:
class Config:
def __init__(self,atoms,pH,pOH,proton_count,conjugate_base_count,timestep,totalEnergy,pressure,temperature,nascent_oxy):
self.atoms=atoms
self.pH=pH
self.pOH=pOH
self.proton_count=proton_count
self.conjugate_base_count=conjugate_base_count
self.nascent_oxy=nascent_oxy
self.timestep=timestep
self.totalEnergy=totalEnergy
self.pressure=pressure
self.temperature=temperature
I want to plot the pH, pOH, proton_count, nascent_oxy against the timestep. One way is to make a list out of all the attributes and do the following :
list1=[x.pH for x in configs]
list1=[x.pOH for x in configs]
Is there a more efficient way of doing this - in terms of memory and reducing the hardcoding?