Functions
Parameter passing by position and by name
- E.g.
def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue',age=6):
print "-- This parrot age ",age," wouldn't", action,
print "if you put", voltage, "Volts through it."
print "-- Lovely plumage, the", type
print "-- It's", state, "!"
>>> parrot(1000)
>>> parrot(action = 'VOOOOOM', voltage = 1000000)
>>> parrot('a thousand', state = 'pushing up the daisies')
>>> parrot('a million', 'bereft of life', 'jump')
>>> parrot(action = 'VOOOOOM')