strange behaviour with keyword arguments and inheritance
Steve Holden
steve at holdenweb.com
Mon Apr 16 22:37:50 EDT 2007
Jun.Jin.act+group.python at gmail.com wrote:
> On Apr 17, 9:36 am, livibetter <livibet... at gmail.com> wrote:
>> On Apr 17, 8:56 am, "matthewperpick" <matthewperp... at gmail.com> 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
>> This should work:
>>
>> class Parent:
>> def __init__(self, ary = []):
>> self.ary = list(ary)
>>
>> And FYIhttp://groups.google.com/group/comp.lang.python/browse_thread/thread/...
>
> 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*.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings http://holdenweb.blogspot.com
More information about the Python-list
mailing list