Re: don't understand behaviour of recursive structure

2009-03-14 Thread Dan Davison
bieff...@gmail.com writes: > On 14 Mar, 17:31, 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) >> > > Most probably, here is the

Re: don't understand behaviour of recursive structure

2009-03-14 Thread MRAB
bieff...@gmail.com wrote: On 14 Mar, 17:31, 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) Most probably, here is the problem : try this

Re: don't understand behaviour of recursive structure

2009-03-14 Thread bieffe62
On 14 Mar, 17:31, 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) > Most probably, here is the problem : try this instead: def new_no

Re: don't understand behaviour of recursive structure

2009-03-14 Thread MRAB
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/gene

Re: don't understand behaviour of recursive structure

2009-03-14 Thread Miles
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/de

don't understand behaviour of recursive structure

2009-03-14 Thread Dan Davison
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') ## Seems OK so far: n0 # {'id': 'n0'