let's say we have the following class Boy:
class Boy():
def __init__(self, name, hair, friend=None):
self.name = name
self.hair = hair
self.friend = friend
and we have some instances of this class and we want to iterate it, and change attributes on these instances while iterating. for example:
ben = Boy("Ben", "red")
sam = Boy("Sam", "black")
roger = Boy("Roger", "yellow", sam)
boys = {ben, sam}
for boy in boys:
boy = roger.friend
The above method only change the attribute of the pointer "boy" and not the instance in the set. What's the best way to approcah this?