[Python-Dev] Py3k: Except clause syntax (original) (raw)

Ron Adam rrr at ronadam.com
Fri Mar 17 04:32:54 CET 2006


Greg Ewing wrote:

Baptiste Carvello wrote:

what about

except with : a program dies "with" an error message, not "as" an error message. No. The exception object you're catching is the value, not something which has a value. I maintain that "as" is the correct word to use here. Greg

I think it reads well with "as" also. +1

To me it's a filter statement. So would catching multiple exceptions have the form:

   except (<type>, <type>) as <name>:

The value is bound to the name if it's type is in the sequence. This would be an indirect assignment similar to.

   if value in list: name = value

Which you can't do directly because you don't have access to the value yet. That's not too different than import which is also an indirect name binding operation of a value you don't have yet.

Cheers, Ron



More information about the Python-Dev mailing list