On 10/15/2013 09:28 AM, PJ Eby wrote: > On Tue, Oct 15, 2013 at 11:52 AM, R. David Murray wrote: >> >> What about making the context manager provide the trapped exception, >> in a fashion similar to what assertRaises does? > > Sadly, that won't work, since context managers provide a value > *before* the block is executed, not after. However, if the CM provides the value before, and the with block accepts it, it can then have the exception added to it: with trap(OSError) as cm: os.unlink('missing.txt') if cm.exc: do_something() -- ~Ethan~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4