Why assert is not a function?

Cameron Simpson cs at cskk.id.au
Fri Mar 5 20:02:51 EST 2021


On 03Mar2021 16:50, Grant Edwards <grant.b.edwards at gmail.com> wrote:
>On 2021-03-03, Chris Angelico <rosuav at gmail.com> wrote:
>> On Thu, Mar 4, 2021 at 1:40 AM Grant Edwards <grant.b.edwards at gmail.com> wrote:
>>
>>> I thought the entire point of asser being a keyword was so that if you
>>> disable asserts then they go away completely: the arguments aren't
>>> even evaluated.
>>
>> It depends on what the point of "removing the assertions" is, but
>> yes, that will indeed still evaluate the arguments. IMO the cost of
>> running assertions isn't that high compared to the value of keeping
>> them (which is why I never run -O), and the performance argument is
>> a weak one compared to the much stronger value of having the actual
>> failing expression available in the exception report.
>
>Good point. I had forgotten about having the expression available in
>the exception output. That's definitly valuable.

Did we all see the recently announced ycecream PyPI module? Very cool!

See: https://github.com/salabim/ycecream

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list