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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -