a = b = 1 just syntactic sugar?
Terry Reedy
tjreedy at udel.edu
Mon Jun 9 22:39:28 EDT 2003
"Steven Taschuk" <staschuk at telusplanet.net> wrote in message
news:mailman.1055177098.5381.python-list at python.org...
> factorial = lambda x: x==0 and 1 or x*selfref.myself(x-1)
If the lambda is immediately name bound, the selfref contortion is not
needed:
>>> factorial = lambda x: x==0 and 1 or x*factorial(x-1)
>>> factorial(6)
720
but it is a clever hack for when it is not.
Terry J. Reedy
More information about the Python-list
mailing list