Re: strange behaviour with keyword arguments and inheritance

2007-04-17 Thread matthewperpick
s some "strange" behaviour > > with keyword arguments and inheritance. > > > = > > > class Parent: > > def __init__(self, ary = []): > > self.ary = ary > > [snip] > > As pointed out earlier, default va

Re: strange behaviour with keyword arguments and inheritance

2007-04-17 Thread Arnaud Delobelle
matthewperpick wrote: > Check out this toy example that demonstrates some "strange" behaviour > with keyword arguments and inheritance. > > = > > class Parent: > def __init__(self, ary = []): > self.ary = ary > [s

Re: strange behaviour with keyword arguments and inheritance

2007-04-17 Thread Bruno Desthuilliers
matthewperpick a écrit : > Check out this toy example that demonstrates some "strange" behaviour > with keyword arguments and inheritance. Nope. It demonstrates that default arguments are eval'd only once (when the def statement is eval'd), which is documented and

Re: strange behaviour with keyword arguments and inheritance

2007-04-16 Thread Alex Martelli
Steve Holden <[EMAIL PROTECTED]> wrote: ... > > livibetter has a better solution. the reason is that you need to > > create a new list object everytime, am I right? > > > Yes, specifically on every *call*. ...and livibetter's solution also creates a new list on every call to Child (that [] pas

Re: strange behaviour with keyword arguments and inheritance

2007-04-16 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Apr 17, 9:36 am, livibetter <[EMAIL PROTECTED]> wrote: >> On Apr 17, 8:56 am, "matthewperpick" <[EMAIL PROTECTED]> wrote: >> >>> Check out this toy example that demonstrates some "strange&qu

Re: strange behaviour with keyword arguments and inheritance

2007-04-16 Thread [EMAIL PROTECTED]
On Apr 17, 9:36 am, livibetter <[EMAIL PROTECTED]> wrote: > On Apr 17, 8:56 am, "matthewperpick" <[EMAIL PROTECTED]> wrote: > > > Check out this toy example that demonstrates some "strange" behaviour > > with keyword arguments and inheritance. &

Re: strange behaviour with keyword arguments and inheritance

2007-04-16 Thread livibetter
On Apr 17, 8:56 am, "matthewperpick" <[EMAIL PROTECTED]> wrote: > Check out this toy example that demonstrates some "strange" behaviour > with keyword arguments and inheritance. > > = > > class Parent: > def __i

Re: strange behaviour with keyword arguments and inheritance

2007-04-16 Thread [EMAIL PROTECTED]
On Apr 17, 8:56 am, "matthewperpick" <[EMAIL PROTECTED]> wrote: > Check out this toy example that demonstrates some "strange" behaviour > with keyword arguments and inheritance. > > = > > class Parent: > def __i

strange behaviour with keyword arguments and inheritance

2007-04-16 Thread matthewperpick
Check out this toy example that demonstrates some "strange" behaviour with keyword arguments and inheritance. = class Parent: def __init__(self, ary = []): self.ary = ary def append(self): self.ary.append(1) class Child(Parent