don't understand behaviour of recursive structure

Miles semanticist at gmail.com
Sat Mar 14 12:52:43 EDT 2009


On Sat, Mar 14, 2009 at 12:31 PM, Dan Davison wrote:
> I'm new to python. Could someone please explain the following behaviour
> of a recursive data structure?
>
> def new_node(id='', daughters=[]):
>    return dict(id=id, daughters=daughters)

This is something of a FAQ:

http://effbot.org/zone/default-values.htm
http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects

-Miles



More information about the Python-list mailing list