I have a problem with PyCharm. The Desctructor Method gets executed, without it even been called. If I try it in the Python IDLE the intepreter doesn´t iniatialize the __del__
method, but in PyCharm it does it
Input:
class Vehicle:
def __init__(self, nme, ve):
self.name = nme
self.velocity = ve
def __del__(self):
print("Object", self.name, "got deleted")
def beschleunigen(self, value):
self.velocity += value
self.output()
def output(self):
print(self.name, self.velocity, "km/h")
car1 = Vehicle("Ford",40)
car2 = Vehicle("BMW", 45)
car1.output()
car2.output()
Output:
Ford 40 km/h
BMW 45 km/h
Object Ford got deleted
Object BMW got deleted
As you can see the del
function was not even called once and he still executes it