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:
getaccbal(child.id,bal)
return bal
may be
for child in children:
bal += getaccbal(child.id, bal)
^^^^^
return bal
if I try this with bal=0, on each recursion bal gets reset to 0 and I always
get a 0 as a result. (If I put bal=20, result is 20). Must be something very
simple that I am missing.
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers