New submission from Daniel Grace:
I was writing code for a class that uses one threading.RLock per object. For
convenience, I wanted to be able to use that lock's context manager and
acquire/release methods without referencing the lock directly, so I opted to
take a shortcut by assigning
R. David Murray added the comment:
magic methods like __enter__ and __exit__ are only looked up on the class,
not on the instance. This is by design.
In some older versions of Python some specific methods (and I think __enter__
and __exit__ were among them for a time) were looked up on the