Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>>
- >>> class ListaQueAvisaQuandoMorre(list):
- ... def __del__(self):
- ... print(f"Lista com id {id(self)} destruida")
- ...
- ...
- >>> a = ListaQueAvisaQuandoMorre([10, 20, 30])
- >>> del a
- Lista com id 140337716637024 destruida
- >>> a = ListaQueAvisaQuandoMorre([10, 20, 30])
- >>> gerad = (v for v in a)
- >>> del a
- >>> print(next(gerad))
- 10
- >>> print(next(gerad))
- 20
- >>> print(next(gerad))
- 30
- >>> print(next(gerad))
- Lista com id 140337716637024 destruida
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- StopIteration
- >>> del gerad
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement