[Python-ideas] with-except-finally blocks
Ethan Furman
ethan at stoneleaf.us
Thu Apr 16 17:35:14 CEST 2015
On 04/16, Steven D'Aprano wrote:
> On Wed, Apr 15, 2015 at 11:39:37PM -0700, Kale Kundert wrote:
>> I'd like to propose a little bit of syntactic sugar: allowing with-blocks to be
>> followed by except- and finally-blocks just like try-blocks. For example:
-1
'with' is highly specialized, and trying to make it more generic will be confusing.
>> Second and more conceptually, it makes sense to think about exception handling
>> in the context of a with-block.
>
> No more than any other block of code. There is nothing special about
> with blocks that go with exception handling [...]
I have to disagree: 'with' blocks are exactly a condensed try/finally, with the
added capability of being able to suppress exceptions -- this makes them very
special with respect to exception handling.
--
~Ethan~
More information about the Python-ideas
mailing list