On 2016-02-08 23:21, Chris Barker wrote: > On Mon, Feb 8, 2016 at 1:51 PM, Victor Stinner <victor.stinner at gmail.com > <mailto: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 "<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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4