with ignored

B

Barrett Lewis

I was recently watching that Raymond Hettinger video on creating Beautiful
Python from this years PyCon.
He mentioned pushing up the new idiom

with ignored(<ignored_exceptions>):
# do some work

I tracked down his commit here http://hg.python.org/cpython/rev/406b47c64480

But am unsure how the yield works in the given situation.

I know about creating generators with yield and have read the docs on how
it maintains state.

I think it works because it is returning control back to the caller
while maintaining the try so if the caller throws it is caught by the
context. Is this correct? I would love an in depth explanation of how this
is working. I am trying to learn as much as possible about the actual
python internals.

Thanks in advance!
-Barrett
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top