Re: [BangPypers] recursion not working

2010-03-15 Thread Kenneth Gonsalves
On Monday 15 Mar 2010 2:14:28 pm Roshan Mathews wrote: > On Mon, Mar 15, 2010 at 13:54, Kenneth Gonsalves wrote: > >for child in children: > >getaccbal(child.id,bal) > > This line returns a "balance" which is discarded. Maybe it should be: > bal += getaccbal(...) ? > yes. t

Re: [BangPypers] recursion not working

2010-03-15 Thread Jeffrey Jose
Good catch. On Mon, Mar 15, 2010 at 2:14 PM, Roshan Mathews wrote: > On Mon, Mar 15, 2010 at 13:54, Kenneth Gonsalves > wrote: > >for child in children: > >getaccbal(child.id,bal) > > This line returns a "balance" which is discarded. Maybe it should be: > bal += getaccbal(.

Re: [BangPypers] recursion not working

2010-03-15 Thread Shekhar
Kenneth Gonsalves wrote: hi, here is a function I have written: def getaccbal(accnt,bal): account = Account.objects.get(pk=accnt) if account.vouch: bal = bal + getledgerob(account) else: children = account.account_set.all() for child in children:

Re: [BangPypers] recursion not working

2010-03-15 Thread Vivek Khurana
On Mon, Mar 15, 2010 at 1:54 PM, Kenneth Gonsalves wrote: > hi, > > here is a function I have written: > > def getaccbal(accnt,bal): >    account = Account.objects.get(pk=accnt) > >    if account.vouch: >        bal = bal + getledgerob(account) >    else: >        children = account.account_set.al

Re: [BangPypers] recursion not working

2010-03-15 Thread Roshan Mathews
On Mon, Mar 15, 2010 at 13:54, Kenneth Gonsalves wrote: >        for child in children: >            getaccbal(child.id,bal) This line returns a "balance" which is discarded. Maybe it should be: bal += getaccbal(...) ? Roshan Mathews ___ BangPypers ma

[BangPypers] recursion not working

2010-03-15 Thread Kenneth Gonsalves
hi, here is a function I have written: def getaccbal(accnt,bal): account = Account.objects.get(pk=accnt) if account.vouch: bal = bal + getledgerob(account) else: children = account.account_set.all() for child in children: getaccbal(child.id,bal