| Store | Cart

Re: [Python-Dev] Issue #26204: compiler now emits a SyntaxWarning on constant statement

From: Chris Angelico <ros...@gmail.com>
Tue, 9 Feb 2016 12:49:50 +1100
On Tue, Feb 9, 2016 at 12:41 PM, MRAB <pyt...@mrabarnett.plus.com> wrote:
> On 2016-02-09 00:53, Guido van Rossum wrote:>>>> The warning for 'assert (cond, msg)' was specifically put in because>> this is a nasty trap. It's *always* a mistaken attempt to write>> 'assert cond, msg' -- usually in an attempt to break a long line>> without using a backslash. I'd actually consider promoting it to a>> syntax error rather than removing the warning.>>>> Compared to other "lint warnings" this one is much nastier -- it is>> also much more certain that it is a mistake. (Much more certain than>> e.g. an undefined variable, which could still be legitimate code due>> to dynamic updates to globals() or builtins.)>> Would there be less chance of confusion if there were some kind of syntax> such as "assert cond with msg"?

Is assert the *only* statement that has a comma separating unrelated
items? Every other statement that uses a comma is separating identical
items (eg "import os, sys" - "os" and "sys" are equivalent), and
tokens that have completely different meaning are separated by a word.
The only other exception I can think of - pun intended - is the old
"except BaseException, e:" syntax, which got dropped in Py3. Maybe
it's time to introduce a new syntax with a view to deprecating the
comma syntax ("use this old syntax if you need to support Python
2.7").

+1.

ChrisA
_______________________________________________
Python-Dev mailing list
Pyth...@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.com

Recent Messages in this Thread
Victor Stinner Feb 08, 2016 05:44 pm
francismb Feb 08, 2016 06:00 pm
xiscu Feb 08, 2016 06:11 pm
Ethan Furman Feb 08, 2016 06:12 pm
Gregory P. Smith Feb 08, 2016 06:06 pm
Ethan Furman Feb 08, 2016 06:15 pm
Ethan Furman Feb 08, 2016 08:39 pm
Guido van Rossum Feb 08, 2016 07:13 pm
Andrew Barnert via Python-Dev Feb 08, 2016 07:46 pm
Victor Stinner Feb 08, 2016 07:51 pm
Guido van Rossum Feb 08, 2016 08:34 pm
Victor Stinner Feb 08, 2016 09:20 pm
Guido van Rossum Feb 08, 2016 09:27 pm
John Mark Vandenberg Feb 08, 2016 09:37 pm
Alexander Walters Feb 08, 2016 09:41 pm
John Mark Vandenberg Feb 08, 2016 09:48 pm
John Mark Vandenberg Feb 09, 2016 02:38 am
Michel Desmoulin Feb 09, 2016 03:09 pm
Alexander Walters Feb 08, 2016 08:09 pm
Victor Stinner Feb 08, 2016 09:23 pm
Alexander Walters Feb 08, 2016 09:28 pm
Victor Stinner Feb 08, 2016 09:51 pm
John Mark Vandenberg Feb 08, 2016 10:14 pm
Terry Reedy Feb 08, 2016 10:19 pm
Yury Selivanov Feb 08, 2016 10:43 pm
Steven DAprano Feb 09, 2016 01:02 am
Yury Selivanov Feb 09, 2016 10:15 pm
Chris Barker Feb 08, 2016 11:21 pm
MRAB Feb 08, 2016 11:48 pm
Chris Barker Feb 09, 2016 12:08 am
Guido van Rossum Feb 09, 2016 12:53 am
MRAB Feb 09, 2016 01:41 am
Guido van Rossum Feb 09, 2016 01:49 am
Chris Angelico Feb 09, 2016 01:49 am
Guido van Rossum Feb 09, 2016 01:52 am
Joseph Martinot-Lagarde Feb 09, 2016 09:57 am
Victor Stinner Feb 09, 2016 10:06 am
Georg Brandl Feb 09, 2016 11:55 am
Messages in this thread