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
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
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
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
[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.
>>> ==
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
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
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
>
>