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
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/XCTF4AP7JKE2KUX4DNV4HUJ23VXNXJIG/
Code of Conduct: http://python.org/psf/codeofconduct/