I have the following code (minus some other operations):
def foobar():
msg=None
if foo:
msg='foo'
else:
msg='bar'
return msg
Is the following better practice for the msg variable?
def foobar():
if foo:
msg='foo'
else:
msg='bar'
return msg
I'm aware that I could simplify the above functions to ternary expressions, however there are operations in each if-else block that I've left out.