[Tutor] Poorly understood error involving class inheritance

Kent Johnson kent37 at tds.net
Tue Oct 6 00:13:41 CEST 2009


On Mon, Oct 5, 2009 at 4:41 PM, David Perlman <dperlman at wisc.edu> wrote:

> I fixed this by changing it to "mods=None" and then setting it in the body
> of the __init__ method.  Works fine now.

That is the correct fix.

> My question is, is this just a quirky misbehavior, or is there a principled
> reason why the code I have shown above only instantiates the empty list in
> the arguments once?

This is a FA. Default arguments are shared between all uses:
http://effbot.org/pyfaq/why-are-default-values-shared-between-objects.htm


More information about the Tutor mailing list