[omaha] Tutorial: Keyword Arguments

Jay Hannah jay at jays.net
Sat Dec 1 17:01:24 CET 2007


I like Python's keyword argument system...   :)

http://docs.python.org/tut/node6.html#SECTION006720000000000000000

Clean and powerful.

Does the colon that starts every simple block have a purpose? (Isn't  
the mandatory indenting sufficient to tell the interpreter what it  
needs to know?)

j



$ cat j.py
def parrot(voltage, state='a stiff', action='voom', type='Norwegian  
Blue'):
     print "-- This parrot wouldn't", action,
     print "if you put", voltage, "volts through it."
     print "-- Lovely plumage, the", type
     print "-- It's", state, "!"

parrot(1000)
print
parrot(action = 'VOOOOOM', voltage = 1000000)
print
parrot('a thousand', state = 'pushing up the daisies')
print
parrot('a million', 'bereft of life', 'jump')



More information about the Omaha mailing list