So this question is not a super concrete question but I can give some examples. I am very afraid of Python since you never know when a variable is pointing at a new object or just have two variables pointing at the same object.
For example I am scared of assigning like this:
def function(self):
number = self.value
return number
In this case I don't want number to change if I change self.value.
Also just copying lists like:
list = [1,2,3]
list2 = list
In this case if I change list, list2 will also be changed which is not desirable. Why would I copy it if i don't want it to be a new variable!
Anyway, I just wonder if anybody knows a safe method to create new variables in these cases or maybe has a complete explanation of when a new object is created and when two variables point at the same object. I want to code in peace and not worry about this all the time because my code is big and I can't sit and check which variables have changed and which have not after every calculation.
The question is related to mutability and immutability so the link to the question: Immutable vs Mutable types, might be good but this is another way of asking the question which might be helpful for some. Also this is more focused on avoiding mutating.