osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


I think they actually read like they would mean slightly different things,
which would make them existing as aliases confusing.

I read `if not val` as "If val isn't true" but i would read `if no val` as
"if val does not exist"

On Thu, Aug 1, 2019 at 4:07 PM Daniel Okey-Okoro <danielokeyokoro at gmail.com>
wrote:

> I think that adding a `no` keyword as an alias for `not` would make for
> more readable, simple, pythonic code.
>
> Take the below:
>
> ```
> if not val:
>   do_thing_because_value_is_falsy()
> ```
>
> could be (is actually understood as):
>
> ```
> if no val:
>    do_thing_because_value_is_falsy()
> ```
>
> I think this PEP is a work-around for an underlying subtle issue with how
> the `not` operator is used.
>
> It has two use-cases:
>
> 1. as a NOT gate for producing opposite boolean values
>
> ```
> opposite = not regular
> ```
>
> 2. as a sort of  ".is_falsy()"  checker; when used with an if statement.
>
> like the first example.
>
>
> This PEP would make the difference between the two usecases explicit.
>
> Thoughts?
>
> Best Intentions,
> Daniel Okey-Okoro.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspealma at redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>