I am wondering what are the best practices for return statements. In particular, is it ok to create an intermediate variable right before a return statement if I can otherwise bypass the variable and have the return statement followed by the value to return?
Example:
def add_me(a=1,b=2,c=3,d=4):
e = a + b + c + d
return e
or would it be better to do:
def add_me(a=1,b=2,c=3,d=4):
return a + b + c + d
What about multiple function calls:
def sub_me=1,b=2,c=3,d=4):
return a - b - c - d
def add_me(a=1,b=2,c=3,d=4):
return a + b + c + d + sub_me() + 1
Aucun commentaire:
Enregistrer un commentaire