def function_serializer(function):
 try:
  return {'function': str(function), 'file': getfile(function), 'line': getsourcelines(function)[1]}
 except IOError:
  return {'function': str(function)}
 except TypeError:
  if isinstance(function, partial):
   return {'partial': function_serializer(function.func)}
  else:
   return {'function': str(function)}

def function_serializer ( function ) : try : return { 'function' : str ( function ) , 'file' : getfile ( function ) , 'line' : getsourcelines ( function ) [ 1 ] } except IOError : return { 'function' : str ( function ) } except TypeError : if isinstance ( function , partial ) : return { 'partial' : function_serializer ( function . func ) } else : return { 'function' : str ( function ) }
serialize the given function for logging by eliot .