On 5/30/2014 7:46 AM, Chris Angelico wrote:

Hmm. I'm not sure that "raises SyntaxError" is any less a part of the
language's promise than "evaluates to twice the value of x" is.

Of course it is. A real SyntaxError cannot be caught immediately.* When new syntax features are added, breaking the raising of a SyntaxError is *not* a consideration. On the other hand, we do not freely change AbcError to XyzError even when the latter would be more 'correct'.

* IE, you cannot type

>>> try: ..
    except SyntaxError: print('caught')

because the SyntaxError during parsing rather than during execution.

Also, consider:

for i in range(5): i*3+2

2
5
8
11
14

If you do this in a script, it's perfectly legal, but won't print
anything. So the REPL is already "chang[ing] the meaning of otherwise
legal Python syntax",

It does not change what is calculated. It adds introspection output as a convenience. The minus is that one may forget that it *is* an addition and use the shortcut when writing a script. (I know I have, occasionally.)

> and what's more, it's making None into a special case:

Which it is, as the 'zero' of the set of Python objects.

for i in range(5): None if i%2 else i

0
2
4

Practicality beats purity. If it's more useful to the end user for
something valid-but-illogical to have a new bit of meaning in
interactive mode, I say go for it.

I disagree.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to