want to delete Bob:
class Person:
def __init__(self, name):
self.name = name
def talk(self):
print(f"Hi, I am {self.name}")
def delete(self):
del self
bob = Person("Bob")
bob.talk()
bob.delete()
bob.talk() #must not to talk
del bob
Use the descriptor del_
use def del(self)
Обсуждают сегодня