Python Glossary Русский

all Python 3operatorfunction

operator.ge

comparison

Return a >= b — the functional form of the "greater than or equal" operator.

Syntax

operator.ge(a, b)

For sets ge tests for a superset: ge({1, 2}, {1}) is true. Strings compare character by character by Unicode code point, so ge('a', 'B') is true: lowercase letters come after uppercase. For case-insensitive comparison normalise the strings with str.casefold.

Examples

import operator
print(operator.ge(2, 2))   # → True
print(operator.ge('b', 'a'))  # → True
scores = [70, 55, 90]
print([operator.ge(s, 60) for s in scores])  # → [True, False, True]
print(operator.ge({1, 2, 3}, {1, 2}))  # → True
print(operator.ge({1, 2}, {2, 3}))  # → False

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy