coding style - In Python, should I use else after a return in an if block? -
first, couldn't find answer in pep 8. doesn't mean isn't in there. feel free point me @ it.
which style prefer?
the first one:
if spam: # stuff. return eggs else: # maybe other stuff. return parrots
or the second one:
if spam: # stuff. return eggs # maybe other stuff. return parrots
it depends, if return parrots, when not return eggs, first 1 more clear. if trying catch error or that, second 1 better.
Comments
Post a Comment