Re: Default function arguments behaving badly

2005-08-24 Thread [EMAIL PROTECTED]
That works perfectly - Thanks! I'm always getting tripped up by the mutability of lists, I should really learn to look out for it more... -- http://mail.python.org/mailman/listinfo/python-list

Re: Default function arguments behaving badly

2005-08-24 Thread Paul McNett
[EMAIL PROTECTED] wrote: > I'm having some trouble with a function I've written in Python: > def myFunction(l1,l2,result=[]): [snipped rest of function and explanation of what it does] > Does anyone know what is going on here? Is there an easy solution? It shined out like a supernova. It has to

Re: Default function arguments behaving badly

2005-08-24 Thread rafi
[EMAIL PROTECTED] wrote: > Hi hi > I'm having some trouble with a function I've written in Python: > > def myFunction(l1,l2,result=[]): > index=0 > for i in l1: > result.append([]) > if type(i)==list: > myFunction(i,l2,result[index]) > else: >

Default function arguments behaving badly

2005-08-24 Thread [EMAIL PROTECTED]
Hi I'm having some trouble with a function I've written in Python: def myFunction(l1,l2,result=[]): index=0 for i in l1: result.append([]) if type(i)==list: myFunction(i,l2,result[index]) else: for j in l2: result[index].appe