Code :
>>> def foo(bar=5): print bar >>> foo() 5 >>> foo(12) 12 >>> foo(bar=12) 12 >>> foo() 5 >>> def bar(baz=[]): print baz >>> bar() [] >>> bar([1,2,3,4]) [1, 2, 3, 4] >>> bar() [] >>> def bar(baz=[]): baz.append(random.randint(0,9)) return baz >>> bar() [1] >>> bar() [1, 1] >>> bar() [1, 1, 5] >>> bar() [1, 1, 5, 5] >>> bar([]) [4] >>> bar([5,1]) [5, 1, 6] >>> bar() [1, 1, 5, 5, 7] >>>
|