compare

Contents

compare#

compare(a, b, operation: str) bool[source]#

Compare two objects using a specific operation. Using this function allows to ask the user the operation he wants (see compare_version for example)

Parameters:
  • a – First object

  • b – Second object

  • operator (str) – Operator to use (>, <, >=, <=, ==)

Returns:

True if the comparison between the two objects is respected

Return type:

bool

Example

>>> compare(1, 2, ">=")
False