def maybe_call(thing, context, args=None, kwargs=None):
 func = maybe_callable(context=context, thing=thing)
 if func:
  thing = func(*(args or ()), **(kwargs or {}))
 return thing

def maybe_call ( thing , context , args = None , kwargs = None ) : func = maybe_callable ( context = context , thing = thing ) if func : thing = func ( * ( args or ( ) ) , ** ( kwargs or { } ) ) return thing
if thing is callable .