aspis.common.prop

aspis.common.prop(p, obj)[source]

Returns the value of property p in object obj if it exists, otherwise return None

Parameters:
  • p (T) – The property to be retrieved from the object.

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

Returns:

The value of property p in object obj if it exists, otherwise return None.

Return type:

R | None

Example

>>> prop("name", {"name": "Alice", "age": 30})
'Alice'
>>> prop("email", {"name": "Alice", "age": 30})