Re: strange behaviour with keyword arguments and inheritance

2007-04-17 Thread matthewperpick
cool .. thanks everyone. here is the aforementioned faq. http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects On Apr 17, 5:16 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > matthewperpick wrote: > > Check out this toy example that demonstrates some "strange" beh

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 > [snip] As pointed out earlier, default val

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 a FAQ. > I have a > very rudime

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" behaviour >>> with keyword arguments and inheritance. >>> ==

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. > > > = > > > class Par

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 __init__(self, ary = []): > self.ary = ary > T

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 __init__(self, ary = []): > self.ary = ary > >