[Python-3000] Problem with grammar for 'except'?
Raymond Hettinger
python at rcn.com
Thu Sep 4 06:25:00 CEST 2008
[Brett]
>I gave a talk last night at the Vancouver Python users group on
> 2.6/3.0, and I tried the following code and it failed during a live
> demo::
>
> >>> try: pass
> ... except Exception, Exception: pass
> File "<stdin>", line 2
> except Exception, Exception: pass
> ^
> SyntaxError: invalid syntax
>
> Now from what I can tell from PEP 3110, that should be legal in 3.0.
> Am I reading the PEP correctly?
Don't think so.
The parens are necessary for a tuple of exceptions
lest it be confused with the old "except E, v" syntax
which meant "except E as e".
Maybe in 3.1, the paren requirement can be dropped.
But for 3.0, it would be a problem given that old
scripts would start getting misinterpreted.
I did something similar for list.sort() by requiring
keyword arguments. That way, we wouldn't have
list.sort(f) running with f as a cmp function 2.6 and
as a key function in 3.0.
Raymond
More information about the Python-3000
mailing list