UniCoreFW

property()

Creates a function that retrieves a property from objects

Implementation

Returns a function that accesses properties

Example

get_name = UniCoreFW.property("name") name = get_name({"name": "John", "age": 30})

Expected output: "John"

Source Code

def property(prop_name): return ( lambda obj: obj.get(prop_name) if isinstance(obj, dict) else getattr(obj, prop_name, None) )