I have a variable which is a list, which contains a large number of people in it. something like:
'citizens = ['John', 'Jack', 'Jill', 'Jonas']`
#imagine hundreds of names
I would like to 'link' a variable, population to the length of this list, so that whenever the list is modified, the population variable will update. Up until now, I have been simply calling a function like so:
def update_population()
global population
population = len(citizens)
but is seems like there would be a more elegant solution, so this can be automatically triggered without my explicitly calling it.
citizensfield and apopulationmethod decorated with@property.