Simple question that I can't find the answer for.
Take the function:
The below looks nice, i.e. more readable, given the else and the aligned spacing between the two return statement. However the else is completely pointless, and that makes it feel a little dirty.
def get_val(self):
if long_var < other_long_var and var < other_var:
return true
else:
return false
Note the two conditions and the long line, this is to express that the following is not applicable in this example:
return true if this else false
However the below is not as readable, but only slightly. It is more elegant as the useless else is omitted.
def get_val(self):
if x:
return true
return false
Is there a Pythonic bias for either of these styles?
If not, is it purely down to the developer?
EDIT: To be clear, it is an example function. I was trying to express the need for a function that has a condition and returns true of false. This is a purely stylistic question