28 self.signed_in = True 29 30 def check_signed_in(self): 31 assert self.signed_in == True, RuntimeError("You are not authorized!")32 33 34class AdminDashboard(BasePage, AdminMixin, SigninMixin, AdminMixin):
Comparisons to the singleton objects, like
None, should be done with identity, not equality. Use
Identity checks are faster than equality checks.
Also, the equality checks can result in unintended behaviour in some cases:
>>> 1 is True False >>> 1 == True True >>> 1.0 is True False >>> 1.0 == True True
value = fx() if value == True: # `==` can cause unintended behaviour print(value) if value != None: print(value)
value = fx() if value is True: # `is` for Identity comparison print(value) if value is not None: print(value)
Equality comparisons might be required in some cases, especially in SQLAlchemy, SQLObject, ORMs, etc. In these cases, it is safe to ignore this issue.