def maybeName(obj):
 try:
  return obj.__name__
 except (AttributeError,):
  return str(obj)

def maybeName ( obj ) : try : return obj . __name__ except ( AttributeError , ) : return str ( obj )
returns an objects __name__ attribute or its string representation .