[Python-ideas] Re: Ensuring asserts are always on in a file

2020-05-19 Thread Brett Cannon
The closest you may ever get to something like this is a clean separation of -O flags instead of the current -O/-OO options. That way you can flip on everything *but* assertion removal. But a per-file directive I don't see happening, and even the flag separation has never caught on enough for

[Python-ideas] Re: Ensuring asserts are always on in a file

2020-05-18 Thread Steven D'Aprano
On Mon, May 18, 2020 at 11:25:39AM +0200, Alex Hall wrote: > I understand this, but I still don't understand in what situation people > use assertions 'correctly'. https://import-that.dreamwidth.org/676.html > To me an assert implies: > > 1. If the condition is false: that's bad, and the

[Python-ideas] Re: Ensuring asserts are always on in a file

2020-05-18 Thread Richard Damon
On 5/18/20 5:25 AM, Alex Hall wrote: > On Mon, May 18, 2020 at 12:03 AM Richard Damon > mailto:rich...@damon-family.org>> wrote: > > On 5/17/20 5:04 PM, Alex Hall wrote: > > Some people (like myself, or the coworkers of [this > >

[Python-ideas] Re: Ensuring asserts are always on in a file

2020-05-18 Thread Alex Hall
On Mon, May 18, 2020 at 12:03 AM Richard Damon wrote: > On 5/17/20 5:04 PM, Alex Hall wrote: > > Some people (like myself, or the coworkers of [this person]( > https://mail.python.org/archives/list/python-ideas@python.org/thread/PLXOXKACKGXN4ZKISDVXLKMFIETWTF63/)) > just like to use asserts as a

[Python-ideas] Re: Ensuring asserts are always on in a file

2020-05-17 Thread Steven D'Aprano
On Sun, May 17, 2020 at 09:04:50PM -, Alex Hall wrote: > Some people (like myself, or the coworkers of [this > person](https://mail.python.org/archives/list/python-ideas@python.org/thread/PLXOXKACKGXN4ZKISDVXLKMFIETWTF63/)) > > just like to use asserts as a convenient way to check things.

[Python-ideas] Re: Ensuring asserts are always on in a file

2020-05-17 Thread Chris Angelico
On Mon, May 18, 2020 at 8:04 AM Richard Damon wrote: > If you really what what you describe, add the following to your code: > > if not __debug__: > > raise AssertionError, "Please don't disable assertions" > > (This won't enable the assertions, but will let the user know that you > need them

[Python-ideas] Re: Ensuring asserts are always on in a file

2020-05-17 Thread Richard Damon
On 5/17/20 5:04 PM, Alex Hall wrote: > Some people (like myself, or the coworkers of [this > person](https://mail.python.org/archives/list/python-ideas@python.org/thread/PLXOXKACKGXN4ZKISDVXLKMFIETWTF63/)) > just like to use asserts as a convenient way to check things. We don't want > asserts