(Jul-26-2020, 03:20 PM)buran Wrote:(Jul-26-2020, 02:32 PM)ifigazsi Wrote: I have a class variable, but I want to change this at instance level, without changing the original class variable, how can i make itThis looks like wrong design - if you want and are going to change it at instance level why it should be class attributee - it should be instance attribute.
Ok, so it seems like wrong design. (first attempt in OOP ) (i tried to update it)
I want to create a initial_data which is accessible by all instances, to start to work with.
Then after a lot of iterations resume to the original (initial) data.
class Something: def __init__(self): self.saved_data = [2,3,4,5] self.data_to_work_with = self.saved_data self.data_to_work_with2 = [x for x in self.saved_data] x = Something() print(x.data_to_work_with is x.saved_data) print(x.data_to_work_with2 is x.saved_data)