Return multiple values from Python

I’m playing with Python for a little pet project (more posts to come I hope) and I just love the way Python deals with returning non scalar values from functions

def getStarSign(name):
    return name,42,'Taurus'

name, age, starSign = getStarSign('Jason Hyland')

print name, age, starSign

This just feels so intuitive. The alternatives in C# are just unsatisfactory: out params, returning tuples or dictionaries or other such ‘hacks’

Leave a Reply

Post Comment