I have searched and I'm unable to come up with any good reason to use python's
There are several differences you appear to have missed:
Context manager get a chance to provide a new object just for the block you are executing. Some context managers just return
self there (like file objects do), but database connection objects could return a cursor object tied to the current transaction.
Context managers are notified just notified of the context ending, but also if the exit was caused by an exception. It can then decide on handling that event or otherwise react differently during exit. Using a database connection as an example again, based on there being an exception you could either commit or abort the transaction.
__del__ is only called when all references to an object are removed. This means you can't rely on it being called if you need to have multiple references to it that you may or may not control the lifetime of. A context manager exit is precisely defined however.
Context managers can be reused, and they can keep state. The database connection again; you create it once, then use it as a context manager again and again, and it'll keep that connection open. There is no need to create a new object each time for this.
This is important for thread locks, for example; you have to keep state so that only one thread can hold the lock at a time. You do this by creating one lock object, then use
with lock: so different threads executing that section each can be made to wait before entering that context.
__exit__ methods form the context manager protocol, and you should only use these if you actually want to manage a context. The goal of context managers is to simplify common
try...except patterns, not to manage the lifetime of a single instance. See PEP 343 – The "with" Statement:
This PEP adds a new statement "with" to the Python language to make it possible to factor out standard uses of try/finally statements.