On Fri, Mar 12, 2021 at 3:37 AM Serhiy Storchaka <storch...@gmail.com> wrote: > > 03.03.21 01:24, Chris Angelico пише: > > On Wed, Mar 3, 2021 at 10:22 AM Mirko via Python-list > > <python-list@python.org> wrote: > >> > >> Am 02.03.2021 um 23:09 schrieb Stestagg: > >>> Ignoring the question about this feature being particularly useful, it > >> > >> It is useful because "assert" is primarily (if not purely and > >> exclusive) a debugging tool during development and testing. > >> > >> In production code you don't want any asserts, but logging. Having > >> "assert" being a function would make it much harder to get rid of it > >> in production code. > >> > > > > Really? > > > > if PRODUCTION: > > def assert(*a, **kw): pass > > > > would work if it were a function :) > > assert(expensive_computation()) >
Do you have any asserts like that, or is that a purely theoretical complaint? I have never once seen anything that costly - usually it'll be something like checking a length (and this isn't C's strlen, since Python can get lengths of all built-in types quickly), or some simple checks. Having assert be a function would not make it much harder to get rid of. It would just make it harder to get the text. ChrisA -- https://mail.python.org/mailman/listinfo/python-list