There is a clear() method in Python that clears the list.
Suppose I have an array of a = [1,2,3] I now need to make an array empty. In my experience I know 2 approaches to solving this problem.
a.clear()a = []
Or OOP's version:
class A: def __init__(self): self.a = [1,2,3] def clear1(self): self.a.clear() def clear2(self): self.a = [] The question is: what is the difference between these two approaches, and if there is a difference, what and when will it be more optimal to use?