If you can live with floating point results:
from math import gamma
def factorial(x):
return gamma(x+1)
This has the advantage of working correctly for non-integer arguments.