Java Finalize Method similar in python <p>I want to determine how can we determine if an object goes out of scope and perform some operations when object goes out of scope </p> <p>In java we have a finalize method which is called by JVM when an object has no more references.</p> <p>I am very new to the python world and want to determine if there is any similar way like Java Finalize where we can perform some operations before and object is destroyed or there are no more references to the object </p>