[Python-Dev] Issue #26204: compiler now emits a SyntaxWarning on constant statement (original) (raw)
Chris Barker chris.barker at noaa.gov
Mon Feb 8 18:21:47 EST 2016
- Previous message (by thread): [Python-Dev] Issue #26204: compiler now emits a SyntaxWarning on constant statement
- Next message (by thread): [Python-Dev] Issue #26204: compiler now emits a SyntaxWarning on constant statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Feb 8, 2016 at 1:51 PM, Victor Stinner <victor.stinner at gmail.com> wrote:
I didn't know. I just checked. It's assert used with a non-empty tuple:
>>> assert ("tuple",)
which is more interesting with a tuple without the parentheses:
t = In [4]: t = True,
In [5]: t
Out[5]: (True,)
works fine, but not if you use an assert:
In [7]: assert True,
File "", line 1
assert True,
^
SyntaxError: invalid syntax I actually like the Warning with the note about the problem better:
:1: SyntaxWarning: assertion is always true, perhaps remove
parentheses?
And, of course, more relevant with something Falsey in the tuple:
In [14]: assert (False,)
:1: SyntaxWarning: assertion is always true, perhaps remove parentheses?
assert (False,)
But I am curious why you get a different error without the parens?
-CHB
--
Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160208/3b8c1265/attachment.html>
- Previous message (by thread): [Python-Dev] Issue #26204: compiler now emits a SyntaxWarning on constant statement
- Next message (by thread): [Python-Dev] Issue #26204: compiler now emits a SyntaxWarning on constant statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]