def safe_hasattr(obj, attr):
 try:
  getattr(obj, attr)
  return True
 except:
  return False

def safe_hasattr ( obj , attr ) : try : getattr ( obj , attr ) return True except : return False
in recent versions of python .