On Tue, Jul 25, 2017 at 5:38 AM, Thomas Jollans <t...@tjol.eu> wrote: > On 2017-07-25 09:28, Chris Angelico wrote: >> It actually does the equivalent of: >> >> finally: >> e = None > > I wonder why it would bother to load None... (as someone not very > familiar with Python at the bytecode level)
If I may hazard a guess, it's because simply deleting the variable will raise a NameError if the variable is not already bound, e.g. if there was no exception and only the finally block is being executed, or if the programmer already deleted it. Assigning None to ensure the variable is bound is likely faster than testing it. -- https://mail.python.org/mailman/listinfo/python-list