
On Tue, Oct 20, 2020 at 01:29:42PM +0900, Stephen J. Turnbull wrote:
Michael Smith writes:
On the other hand, assert has no parentheses, and gets committed for posterity everywhere.
ISTR that assert was not converted to a function along with print because it's a control flow construct.
Correct. Not only can the entire `assert` be turned into a no-op by the compiler, but the second part of the assertion is only evaluated if the assert fails: py> assert True, wibble() py> assert False, wibble() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'wibble' is not defined You can't do that with a function call. `print`, on the other hand, does absolutely nothing that can't be handled by a function. There's nothing special about `print`. -- Steve