If I want to return more that one variable from a function in Python I have been doing the following:
def foo():
firstName = 'Bob'
lastName = 'Jones'
return [firstName, lastName]
Then if I wanted to find only the first name I would do this
[firstName, dummy] = foo()
However, say I initially had the function
def fooInitial():
firstName = 'Bob'
return firstName
and I called this from many parts of my code, if I wanted to add the lastName as another output the way I have been doing, I would have to change everywhere else in my code that was calling it.
Is there a way to do something similar to Matlab where calling a = foo() gives me the first name (not the first and last in a list) and [a,b]=foo() gives me the first and last?