I actually use Python and Flask for my devblog. I know that depending of the language, it is advisable to use a explicit else
when it is not obligatory, but I don't know how it's work in Python.
By example, I have a a function with a if
that return something if the statement is true. So, The else
is not necessary because with or without it, the execution continue normally.
def foo(bar):
if not isinstance(foo, list):
return "an error"
else: # not necessary
return "something"
So, I should use it like this, or like :
def foo(bar):
if not isinstance(foo, list):
return "an error"
return "something"