[Tutor] Maximum recursion depth problem.
Wesley Brooks
wesbrooks at gmail.com
Tue Aug 3 12:48:41 CEST 2010
Morning Peter,
Thanks, that was something I was unaware of! Not sure how I hadn't
bumped into that before!
Cheers,
Wesley.
On 3 August 2010 11:40, Peter Otten <__peter__ at web.de> wrote:
> Wesley Brooks wrote:
>
>> I'm having real difficulty understanding why the following is not
>> working and hoped I've either missed something obvious of I'm doing
>> something wrong!
>>
>> class A:
>> def break_down(self, value, base, broken_list=[]):
>
>> I'm a little stumped as I don't think I'm using any global or class
>> variables? Any help would be much appreciated.
>
> You are on the right track, the default value for broken_list is
> evaluated only once; Modifications during an invocation of the
> break_down() method are visible when break_down() is called again later.
>
> See also
>
> http://docs.python.org/faq/design.html#why-are-default-values-shared-between-objects
>
> Peter
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list