Why assert is not a function?

Terry Reedy tjreedy at udel.edu
Tue Mar 2 21:33:53 EST 2021


On 3/1/2021 5:51 PM, Marco Sulla wrote:
> I have a curiosity. Python, as many languages, has assert as a
> keyword. Can't it be implemented as a function? Is there an advantage
> to have it as a keyword?

One does not need to turn the test expression into a function.  One does 
not need to wrap the message expression to delay evaluation.


-- 
Terry Jan Reedy



More information about the Python-list mailing list