/RethinkDB Python

ReQL command: ~, not_

Command syntax

bool.not_() → bool
not_(bool) → bool
(~bool) → bool


Compute the logical inverse (not) of an expression.

not_ can be called either via method chaining, immediately after an expression that evaluates as a boolean value, or by passing the expression as a parameter to not_. All values that are not False or None will be converted to True.

You may also use ~ as a shorthand operator.

Example: Not true is false.


These evaluate to false.

Note that when using ~ the expression is wrapped in parentheses. Without this, Python will evaluate r.expr(True) first rather than using the ReQL operator and return an incorrect value. (~True evaluates to −2 in Python.)

Example: Return all the users that do not have a “flag” field.

    lambda users: (~users.has_fields('flag'))

Example: As above, but prefix-style.

    lambda users: r.not_(users.has_fields('flag'))

Related commands

Get more help

Couldn't find what you were looking for?

© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.