don't understand behaviour of recursive structure
MRAB
google at mrabarnett.plus.com
Sat Mar 14 12:54:18 EDT 2009
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)
>
> n0 = new_node(id='n0')
> n1 = new_node(id='n1')
>
[snip]
See
http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects
More information about the Python-list
mailing list