The only way I can think of to do this amounts to giving the function a name:

fact = lambda x: 1 if x == 0 else x * fact(x-1)

or alternately, for earlier versions of python:

fact = lambda x: x == 0 and 1 or x * fact(x-1)

Update: using the ideas from the other answers, I was able to wedge the factorial function into a single unnamed lambda:

>>> map(lambda n: (lambda f, *a: f(f, *a))(lambda rec, n: 1 if n == 0 else n*rec(rec, n-1), n), range(10))
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]

So it's possible, but not really recommended!

Answer from Greg Hewgill on Stack Overflow
🌐
Python Examples
pythonexamples.org › python-recursive-lambda-function
Python – Recursive Lambda Function
Here it is! Our lambda function that can take a number, and return its factorial using recursion technique. In this example, we shall use the lambda function that we defined above, and find the factorial of 5.
🌐
Dot Net Tutorials
dotnettutorials.net › home › recursive and lambda functions in python
Recursive Function in Python with Examples - Dot Net Tutorials
April 21, 2021 - As part of this article, you will ... Let’s understand this with an example. Let’s consider a function which calculates the factorial of a number....
🌐
Rip Tutorial
riptutorial.com › recursive lambda using assigned variable
Python Language Tutorial => Recursive Lambda using assigned variable
One method for creating recursive lambda functions involves assigning the function to a variable and then referencing that variable within the function itself. A common example of this is the recursive calculation of the factorial of a number - such ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › recursion-in-python
Recursion in Python - GeeksforGeeks
Example 2: This code defines a recursive function to calculate nth Fibonacci number, where each number is the sum of the two preceding ones, starting from 0 and 1.
Published   1 week ago
🌐
Virtual Maestro
virtualmaestro.in › 2020 › 04 › 07 › learning-python-part-24-recursive-function-lambda-function
Learning Python Part-24: Recursive function, Lambda Function – Virtual Maestro
April 7, 2020 - Python Recursive Function:Recursion is the process of defining something in terms of itself. We know that in Python, a function can call other functions. It is even possible for the function to call itself. These type of construct are termed as recursive functions.Following is an example of recursive function to find the factorial of an integer.Factorial…
🌐
Quora
quora.com › Can-you-explain-how-to-use-recursion-and-lambda-functions-in-Python-to-recursively-sum-up-lists
Can you explain how to use recursion and lambda functions in Python to recursively sum up lists? - Quora
Answer: “Can you explain how to use recursion and lambda functions in Python to recursively sum up lists?” I can think of ways to use recursion, or ways to use lambda functions, but no obvious way to use them together. Recursion. We have a function which calls itself.
🌐
Medium
medium.com › inspiredbrilliance › aws-lambda-long-running-functions-using-tail-recursion-6f5b59133a94
AWS Lambda: Long-Running Functions using Tail Recursion | by Kulbhushan Singhal | inspiringbrilliance | Medium
October 17, 2019 - This method returns the milliseconds left before the Lambda function execution will time out. To achieve recursion, we keep checking the time remaining in the loop while processing the items and make a recursive call when the time remaining is less than 10 seconds. Below Python code snippet ...
Find elsewhere
🌐
Wikipedia
en.wikipedia.org › wiki › Anonymous_recursion
Anonymous recursion - Wikipedia
November 26, 2025 - This is mainly of academic interest, ... that the lambda calculus has recursion, as the resulting expression is significantly more complicated than the original named recursive function. Conversely, the use of fixed-pointed combinators may be generically referred to as "anonymous recursion", as this is a notable use of them, though they have other applications. This is illustrated below using Python...
🌐
Python Examples
pythonexamples.org › python-lambda
Python Lambda Function
In the following example, we define a lambda function with no arguments, and returns 6 when called. #lambda function six = lambda : 6 #call lambda function result = six() print(result) ... You can design a recursion function using lambda function. According to the syntax of Python Lambda function, ...
🌐
Plain English
python.plainenglish.io › how-to-write-terrible-code-using-recursive-python-lambdas-e41374d278f1
How to Write Terrible Code, Using Recursive Python Lambdas | by Filip Sufitchi | Python in Plain English
May 15, 2020 - Do you ever code deliberately awful stuff, just because you can? Here’s a way to do it using lambdas that call themselves recursively.
🌐
DEV Community
dev.to › otumianempire › python3-programming-exercise-12-c-2j9j
Python3 Programming - Exercise 12 c - Recursive and lambda functions - DEV Community
November 16, 2021 - In the first func, the lambda function was assigned to inc. inc was called and an argument of value, 4 was passed. So we can say that inc is a function. In the second func, an argument of value 4 was passed to the lambda function.
🌐
Msdotnet
msdotnet.co.in › 2020 › 09 › lambda-and-recursive-functions-in-python.html
Lambda and Recursive functions in python | MY NET Tutorials
In above example,I have calculated factorial of given number.Here i have used recursive function to calculate the factorial value of given number as given below:- ... For More.... ... Powered by Blogger. C# Language Asp.Net Complete Python Course Real Time Projects Ajax C# Q.
🌐
Blogger
metapython.blogspot.com › 2010 › 11 › recursive-lambda-functions.html
metapython: Recursive Lambda Functions
November 6, 2010 - from inspect import currentframe from types import FunctionType lambda_cache = {} def myself (*args, **kw): caller_frame = currentframe(1) code = caller_frame.f_code if not code in lambda_cache: lambda_cache[code] = FunctionType(code, caller_frame.f_globals) return lambda_cache[code](*args, **kw) if __name__ == "__main__": print "Factorial of 5", (lambda n: n * myself(n - 1) if n > 1 else 1)(5) (just note that it won't preserve default parameters for the lambda function - I found no way of getting a reference to those) ... this is one of the best python articles I have ever read!! thanks for settinging an argument with a co-worker about if python can do anonymous recursion :)ReplyDelete ... The first example is not actually designed to work - the second example does recursion using the "myself" call.Delete
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-lambda-anonymous-functions-filter-map-reduce
Python Lambda Functions - GeeksforGeeks
The lambda function takes x as input. It uses nested if-else statements to return "Positive," "Negative," or "Zero." Below example checks divisibility by 2 and returns "Even" or "Odd" accordingly.
Published   2 weeks ago