Recursively traverse linked list -- help!

Jason Orendorff jason at jorendorff.com
Wed Feb 20 16:18:26 EST 2002


Paul Rubin wrote:
> "Terry Reedy" <tjreedy at home.com> writes:
> > def f(val):
> >   global f
> >   f = val and f1 or f2
> >   return f(val)
> 
> This is not tail recursion.  The "global f" declaration shadows
> the "f" that names the function.

That's not true.  The f that names the function is global anyway.
It's the assignment that causes the problem.

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list