Re: default value for __init__ doesn't work

2010-09-10 Thread 人言落日是天涯,望极天涯不见家
On Sep 11, 1:55 pm, 人言落日是天涯,望极天涯不见家 wrote: > On Sep 11, 1:14 pm, Benjamin Kaplan wrote: > > > > > On Sat, Sep 11, 2010 at 12:38 AM, 人言落日是天涯,望极天涯不见家 > > wrote: > > > Please look at below code snippet: > > > class test(): > > >    def __init__(self, a, dic={}): > > >        self.a = a > > >      

Re: default value for __init__ doesn't work

2010-09-10 Thread 人言落日是天涯,望极天涯不见家
On Sep 11, 1:14 pm, Benjamin Kaplan wrote: > On Sat, Sep 11, 2010 at 12:38 AM, 人言落日是天涯,望极天涯不见家 > wrote: > > Please look at below code snippet: > > class test(): > >    def __init__(self, a, dic={}): > >        self.a = a > >        self.dic = dic > >        print('__init__ params:',a, dic) > > T

Re: default value for __init__ doesn't work

2010-09-10 Thread Benjamin Kaplan
On Sat, Sep 11, 2010 at 12:38 AM, 人言落日是天涯,望极天涯不见家 wrote: > Please look at below code snippet: > class test(): >    def __init__(self, a, dic={}): >        self.a = a >        self.dic = dic >        print('__init__ params:',a, dic) > This is a pretty popular mistake to make. Default arguments ar

default value for __init__ doesn't work

2010-09-10 Thread 人言落日是天涯,望极天涯不见家
Please look at below code snippet: class test(): def __init__(self, a, dic={}): self.a = a self.dic = dic print('__init__ params:',a, dic) def get(self): self.dic[1] = 2 self.dic[4] = 5 def foo(): print('in foo function') bar = test(1) b