Re: a + not b

2021-03-03 Thread MRAB
On 2021-03-04 03:39, Avi Gross via Python-list wrote: As a guess, Rob, precedence rules for not may not bind as strongly as you think. 1 + (not 1) With parentheses, "not 1" is a subexpression that should be performed first and might return the value "False" 1 + False treats False in a numeri

RE: a + not b

2021-03-03 Thread Avi Gross via Python-list
As a guess, Rob, precedence rules for not may not bind as strongly as you think. 1 + (not 1) With parentheses, "not 1" is a subexpression that should be performed first and might return the value "False" 1 + False treats False in a numeric context as a zero so evaluates to 1. But 1 + not 1

a + not b

2021-03-03 Thread Rob Cliffe via Python-list
I can't work out why     1 + - 1     1 + (not 1) are legal syntax, but     1 + not 1 isn't. Is there a good reason for this? Thanks Rob Cliffe -- https://mail.python.org/mailman/listinfo/python-list

Re: Why assert is not a function?

2021-03-03 Thread Barry Scott
> On 3 Mar 2021, at 18:41, Chris Angelico wrote: > > On Thu, Mar 4, 2021 at 5:25 AM Barry Scott > wrote: >> >> >> >>> On 3 Mar 2021, at 17:35, David Lowry-Duda wrote: >>> assert condition, expression Only is condition is false with expressio

Re: Why assert is not a function?

2021-03-03 Thread Chris Angelico
On Thu, Mar 4, 2021 at 5:25 AM Barry Scott wrote: > > > > > On 3 Mar 2021, at 17:35, David Lowry-Duda wrote: > > > >> assert condition, expression > >> > >> Only is condition is false with expression be evaluated. > >> So you can safely do expensive things I the expression with incuring > >> and

Re: Why assert is not a function?

2021-03-03 Thread Barry Scott
> On 3 Mar 2021, at 17:35, David Lowry-Duda wrote: > >> assert condition, expression >> >> Only is condition is false with expression be evaluated. >> So you can safely do expensive things I the expression with incuring >> and cost if the condition is True. > > I think I've only every used

Re: Why assert is not a function?

2021-03-03 Thread David Lowry-Duda
> assert condition, expression > > Only is condition is false with expression be evaluated. > So you can safely do expensive things I the expression with incuring > and cost if the condition is True. I think I've only every used a string as the expression. Have you found it useful to use compli

Re: Why assert is not a function?

2021-03-03 Thread Chris Angelico
On Thu, Mar 4, 2021 at 1:40 AM Grant Edwards wrote: > > On 2021-03-02, Chris Angelico wrote: > > On Wed, Mar 3, 2021 at 10:22 AM Mirko via > > Python-list> wrote: > > > >> In production code you don't want any asserts, but logging. Having > >> "assert" being a function would make it much harder

Re: editor recommendations?

2021-03-03 Thread Lele Gaifax
Cameron Simpson writes: > My fingers know vim. Some others' fingers know emacs. Emacs has also an Evil[1] mode, that mimics some vi/vim features. I suggest taking a look at Doom Emacs[2], a popular so-called "Emacs distribution", that provides an out-of-the-box great experience with a modular c

Re: Why assert is not a function?

2021-03-03 Thread Grant Edwards
On 2021-03-02, Chris Angelico wrote: > On Wed, Mar 3, 2021 at 10:22 AM Mirko via > Python-list> wrote: > >> 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 PRODUCTI

Re: Why assert is not a function?

2021-03-03 Thread Terry Reedy
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 me