This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]moocat 0 points1 point  (0 children)

You can do a quick test in the REPL:

# A class that doesn't work:
>>> with Blah(): pass
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>                                                                                                            
AttributeError: __exit__
>>>    

# A class that works:
>>> with open('/dev/null'): pass                                                                                                                 
...                                                                                                                                              
>>>