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 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.