Hi, Thanks for reply.
I went through the link you provided. It was very helpful. What I understood is this, --> Objects are created for default argument types, inside the function object. This happens only once when the function definition statement is executed. These objects persist between function calls and not destroyed/garbage collected. --> Since List is a mutable object, changes are made to the same object and hence it is visible between function calls. Is my understanding correct ? If so, I have a small doubt regarding function arguments. Are objects for arguments, that persist between function calls, created during function definition ONLY when they have default values ? OR Objects are created for arguments irrespective of whether it has a default value or not, but they are not persistent ( i.e a new object is created for every function call ) ? Regards, Nikhil On Tue, May 26, 2009 at 6:29 PM, Christian Witts <cwi...@compuscan.co.za>wrote: > It is a well known Python gotcha. Take a read through the "Mutable > defaults for function/method arguments" section of > http://www.ferg.org/projects/python_gotchas.html#contents_item_6 > > Hope that helps your understanding. > > -- > Kind Regards, > Christian Witts > > >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor