A conditional statement represents a branch in our code. A place where things could go one way, or they could go the other. That, at least, is traditionally what they are. Adam's co-worker took a different approach.

if user:
    if user.is_owner():
        self.template_values['login_url'] = users.create_login_url(self.request.uri)
    else:
        self.template_values['login_url'] = users.create_login_url(self.request.uri)
else:
    self.template_values['login_url'] = users.create_login_url(self.request.uri)

Like a lot of Python code, we start with a null check- if user is not null, we check if they're an owner. Whether they are, or not, or whether the user variable is null, or not, we do the same thing in every case: set a login_url value.

Adam is on "code maintenance" duties, and is afraid that he'll have plenty of maintenance work going forward.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!