Re: Constructor re-initialization issue

2008-06-03 Thread pythonreptile
On Jun 3, 12:59 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Jun 3, 6:11 pm, [EMAIL PROTECTED] wrote: > > > > > Hello all, > > > I have come across this issue in Python and I cannot quite understand > > what is going on. > > > class Param(): > > def __init__(self, data={}, condition=False)

Re: Constructor re-initialization issue

2008-06-03 Thread Michael Mabin
Changing the default for data to None and creating a new dict inside your function might handle this. But I don't know what it is you want. It never even occurred to me that this behavior might be desired in the first place. class Param(object): def __init__(self,data=None,condition=False):

Re: Constructor re-initialization issue

2008-06-03 Thread George Sakkis
On Jun 3, 6:11 pm, [EMAIL PROTECTED] wrote: > Hello all, > > I have come across this issue in Python and I cannot quite understand > what is going on. > > class Param(): > def __init__(self, data={}, condition=False): > if condition: > data['class']="Advanced" > pri

Re: Constructor re-initialization issue

2008-06-03 Thread Mike Kent
On Jun 3, 6:11 pm, [EMAIL PROTECTED] wrote: > Hello all, > > I have come across this issue in Python and I cannot quite understand > what is going on. > > class Param(): > def __init__(self, data={}, condition=False): > if condition: > data['class']="Advanced" > prin

Constructor re-initialization issue

2008-06-03 Thread pythonreptile
Hello all, I have come across this issue in Python and I cannot quite understand what is going on. class Param(): def __init__(self, data={}, condition=False): if condition: data['class']="Advanced" print data In the previous example, I expect the variable data to