You can use directly the gettattr(,, None) and skip the hasattr