logic behind the assert syntax?

Niels Diepeveen niels at endea.demon.nl
Mon Aug 28 19:37:59 EDT 2000


Jeremy Hylton schreef:
> assert is special, because the assert statement can take a comma as
> part of its syntax.  

In fact, it seems to take any number of commas, even if it doesn't know
what to do with them.

>>> assert 0 == 1, (2, 3)
Traceback (innermost last):
  File "<pyshell#22>", line 1, in ?
    assert 0 == 1, (2, 3)
AssertionError: (2, 3)

Makes sense.

>>> assert 0 == 1, 2, 3
SyntaxError: invalid syntax

Not really what I'd expect, going by the language reference.

-- 
Niels Diepeveen
Endea automatisering




More information about the Python-list mailing list