Skip to content

Instantly share code, notes, and snippets.

@mithrandi
Created Sep 13, 2017
Embed
What would you like to do?
maybe
def maybe(f, v, default=None):
"""
Return C{f(v)} if C{v} is not C{None}, otherwise return C{default}.
"""
if v is None:
return default
return f(v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment