aspis.common.prop_eq

aspis.common.prop_eq(p, value, obj)[source]

Returns a check if the specified property of an object equals the given value.

Parameters:
  • p (T) – The key of the property to check in the object.

  • value (R) – The value to compare against.

  • obj (Mapping[T, R] | object) – The object to check the property.

Returns:

True if the value of the specified property equals value; otherwise, False.

Return type:

bool

Example

>>> is_name_john = prop_eq("name", "John")
>>> is_name_john({"name": "John", "age": 30})
True
>>> is_name_john({"name": "Doe", "age": 25})
False