Menu

gitpiper

check_prop python Code Snippet in 2024

functionintermediate

Last Updated: 15 December 2024

Creates a function that will invoke a predicate function for the specified property on a given object.

  • Return a lambda function that takes an object and applies the predicate function, fn to the specified property.
def check_prop(fn, prop): return lambda obj: fn(obj[prop])
check_age = check_prop(lambda x: x >= 18, 'age') user = {'name': 'Mark', 'age': 18} check_age(user) # True

python snippet similar to check_prop For You in December 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️