[Pythonmac-SIG] How do you use macfs.FInfo?

Joseph J. Strout joe@strout.net
Mon, 11 Oct 1999 11:10:49 -0700


At 10:23 AM -0400 10/11/99, Richard Gordon wrote:

>So, my question is where do you hide a cumulative counter when a 
>function is recursive?

You return it.  E.g.:

	def process(spam):
		"process spam and all sub-spams, and return a total"
		total = 0
		... do some processing that increments localTotal...
		... and now, for sub-spams:
		for subspam in subspams(spam):
			total = total + process(subspam)

		# all done!  return the grand total
		return total

See how the total is a sum of any local increments, plus all the 
totals of the sub-spams?

Cheers,
-- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout           Biocomputing -- The Salk Institute |
|    joe@strout.net             http://www.strout.net              |
`------------------------------------------------------------------'