def getattr_str(obj, attr, fmt=None, fallback='?'):
 if hasattr(obj, attr):
  if (fmt is not None):
   return (fmt % getattr(obj, attr))
  return str(getattr(obj, attr))
 return fallback

def getattr_str ( obj , attr , fmt = None , fallback = '?' ) : if hasattr ( obj , attr ) : if ( fmt is not None ) : return ( fmt % getattr ( obj , attr ) ) return str ( getattr ( obj , attr ) ) return fallback
returns a string of the given objects attribute .