[Python-Dev] PEP 343 - Abstract Block Redux

Arnold deVos adv at langdale.com.au
Mon May 16 05:52:59 CEST 2005


Guido van Rossum wrote:
> [...] But some of the claims from PEP 3XX seem to be incorrect now: Nick
> claims that a with-statement can abstract an except clause, but that's
> not the case; [...]

Sorry for being a lurker, but can I try and expand this point.

The options:

- If we don't allow the except clause in the generator, the exception 
can't be examined there.

- If we do allow the except clause we must (IMO) also allow the 
generator to suppress the exception. It would be surprising behaviour if 
an a caught exception was re-raised without an explicit raise statement.

An argument:

Despite the control-flow-macros-are-harmful discussion, I see nothing 
wrong with a block controller swallowing its block's exceptions because:

- In most proposals it can raise its own exception in place of the 
block's exception anyway.

- In the following example there is nothing surprising if controller() 
swallows block()'s exception:

def block():
	# do stuff
	raise E
controller(block)

Perhaps we don't want the block controller statement to have as much 
power over its block as controller() has over block() above. But 
handling an exception is not so radical is it?

- Arnold.



More information about the Python-Dev mailing list