Re: [Tutor] How default arg of function works

2018-06-14 Thread Mats Wichmann
On 06/14/2018 05:01 AM, Deepak Dixit wrote: > Thanks a lot for this information. > > On Thu, Jun 14, 2018, 4:28 PM Alan Gauld via Tutor wrote: >> Yes, the default argument object is created when the >> function is defined (ie before it is even called the >> first time) and the same reference to

Re: [Tutor] How default arg of function works

2018-06-14 Thread Deepak Dixit
Thanks a lot for this information. On Thu, Jun 14, 2018, 4:28 PM Alan Gauld via Tutor wrote: > On 14/06/18 08:40, Deepak Dixit wrote: > > You mean that for default args and passed args of mutable type, python > uses > > different object and same reference will be used for further calling of > th

Re: [Tutor] How default arg of function works

2018-06-14 Thread Alan Gauld via Tutor
On 14/06/18 08:40, Deepak Dixit wrote: > You mean that for default args and passed args of mutable type, python uses > different object and same reference will be used for further calling of the > function. Yes, the default argument object is created when the function is defined (ie before it is e

Re: [Tutor] How default arg of function works

2018-06-14 Thread Deepak Dixit
You mean that for default args and passed args of mutable type, python uses different object and same reference will be used for further calling of the function. Now one more thing I want to ask you that how can I get deep understanding of python like how list, dictionary works internally and other

Re: [Tutor] How default arg of function works

2018-06-14 Thread Alan Gauld via Tutor
On 14/06/18 08:04, Deepak Dixit wrote: > def test2(nums=[]): > nums.append(len(nums)); > return nums > > print 'test2()', test2() > print 'test2([1,2,3])', test2([1,2,3]) > print 'test2([1,2])', test2([1,2]) > print 'test2()', test2() > print 'test2()', test2() > > Calling test2