0

I get different opinions on this topic and have to settle on one idea.

Is this useful to do in python? Because I read that Python objects are automatically destroyed, but for safety reasons del should be explicitly called to delete instantiated objected.

class A:            
    def __init__(self):  
        print("A")  

class B:            
    def __init__(self):  
        print("B")  
    
class base:         
    def __init__(self):
        self._a = A()
        self._b = B()

    def __del__(self):
        del self._a
        del self._b

_base = base()
del _base

In other documents I have read that the context manager or CPython can be used for this purpose, but I don't know how or whether it is necessary.

Gaston
  • 185
  • 8

0 Answers0