On 2016-02-08 23:21, Chris Barker wrote:
On Mon, Feb 8, 2016 at 1:51 PM, Victor Stinner <victor.stin...@gmail.com
<mailto:victor.stin...@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 "<ipython-input-7-38940c80755c>", line 1
assert True,
^
SyntaxError:invalid syntax
I actually like the Warning with the note about the problem better:
<stdin>:1: SyntaxWarning: assertion is always true, perhaps remove
parentheses?
And, of course, more relevant with something Falsey in the tuple:
In [*14*]: assert (False,)
<ipython-input-14-05f425f558c4>:1: SyntaxWarning: assertion is always
true, perhaps remove parentheses?
assert (False,)
But I am curious why you get a different error without the parens?
Try:
help('assert')
You'll see that in "assert (True,)", the tuple (an object) is the first
condition (and probably a mistake), whereas in "assert True,", the True
is the condition and the second expression (after the comma) is missing.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com