Fwd: Re: PEP: add a `no` keyword as an alias for `not`

---------- Forwarded message --------- From: Daniel Okey-Okoro <danielokeyokoro@gmail.com> Date: Thu, Aug 1, 2019 at 1:37 PM Subject: Re: [Python-ideas] Re: PEP: add a `no` keyword as an alias for `not` To: Chris Angelico <rosuav@gmail.com>
not a strong enough justification for breaking any code that uses "no" in any other way.
This is a very crucial point I didn't consider. ------------------------------------------------------------ What if we could lexically limit it to `if no {{everything else in the if block}}`? I think that would sufficiently protect us from unintentionally breaking people's code. -----------------------------------------------------------
The bar for creating new keywords is extremely high
I'm grateful that it is. I think python is awesome. And I trust the community/council to keep it awesome. If the idea doesn't make sense to most people then I'm happy with it never getting picked up. Just sharing an idea. On Thu, Aug 1, 2019 at 1:12 PM Chris Angelico <rosuav@gmail.com> wrote:
-- Best Intentions, Daniel Okey-Okoro. -- Best Intentions, Daniel Okey-Okoro.

On Aug 1, 2019, at 13:38, Daniel Okey-Okoro <danielokeyokoro@gmail.com> wrote:
There are some cases where a “contextual keyword” that’s usable as an identifier outside of a specific syntactic construct could avoid ambiguity, but this isn’t one of them, because the thing immediately after the `if` in an if statement can be–and often is—an identifier. For example: total = len(votes) yes, no, other = (len(part) for part in partition_votes(votes)) if no >= total//2: # etc. I even found an actual example of the equivalent in some C++ code I had on my hard drive: if (no == ask(…)) { // … } In Python, that would be: if no == ask(…): Also, even if that weren’t a problem, this would be very misleading syntax. If I can write `if no sales:` I’d expect to be able to write `if isopen and no sales:` or `0 if no sales else mean(sales)` or `skip = no sales` or any of the other things I can do with `not` and other operators rather than special syntax. Also, I could still write `if no sales and isopen:`, but it would do the wrong thing if `no` is special syntax that reverses the sense of the `if` rather than a normal operator that binds more tightly than `and`.

On Aug 1, 2019, at 13:38, Daniel Okey-Okoro <danielokeyokoro@gmail.com> wrote:
There are some cases where a “contextual keyword” that’s usable as an identifier outside of a specific syntactic construct could avoid ambiguity, but this isn’t one of them, because the thing immediately after the `if` in an if statement can be–and often is—an identifier. For example: total = len(votes) yes, no, other = (len(part) for part in partition_votes(votes)) if no >= total//2: # etc. I even found an actual example of the equivalent in some C++ code I had on my hard drive: if (no == ask(…)) { // … } In Python, that would be: if no == ask(…): Also, even if that weren’t a problem, this would be very misleading syntax. If I can write `if no sales:` I’d expect to be able to write `if isopen and no sales:` or `0 if no sales else mean(sales)` or `skip = no sales` or any of the other things I can do with `not` and other operators rather than special syntax. Also, I could still write `if no sales and isopen:`, but it would do the wrong thing if `no` is special syntax that reverses the sense of the `if` rather than a normal operator that binds more tightly than `and`.
participants (2)
-
Andrew Barnert
-
Daniel Okey-Okoro