How can I easily find out if a Python class accepts the with keyword?

Viewed 45

The only time I ever use the with keyword is when reading and writing files, mostly because that's the only case I actually know that I can use it. I can imagine there are numerous instances where I preferably could have used with, but didn't know a class or method accepted it.

So, how do I detect instances where the with keyword can be used?

1 Answers
Related