Avoiding argument checking in recursive calls

andrew cooke andrew at acooke.org
Wed Feb 11 04:58:54 EST 2009

Terry Reedy wrote:
> Reverse the test order
> def fact(n):
>      if n > 0: return fact(n-1)*n
>      if n == 0: return 1
>      raise ValueError

sweet!  but is this generally possible?  ie: did you think this up for
this question or is it an idiom that you find yourself using often?


More information about the Python-list mailing list