def maybe_callable(thing, context=None):
 if callable(thing):
  return thing
 if isinstance(thing, six.string_types):
  thing = getattr(context, thing, None)
  if callable(thing):
   return thing
 return None

def maybe_callable ( thing , context = None ) : if callable ( thing ) : return thing if isinstance ( thing , six . string_types ) : thing = getattr ( context , thing , None ) if callable ( thing ) : return thing return None
if thing is callable .