Dr. Phillip M. Feldman writes:
I currently have a function that uses a list internally but then returns the
list items as separate return
values as follows:
if len(result)==1: return result[0]
if len(result)==2: return result[0], result[1]
(and so on). Is there a cleaner way to accomplish the same thing?
The suggestions to return result
or if needed tuple(result) are good,
if a sequence is expected.
But perhaps better if each element has separate meaning:
return a defaultdict;
document the keys.
http://docs.python.org/library/collections.html#collections.defaultdict
Cheers,
Alan Isaac
--
http://mail.python.org/mailman/listinfo/python-list