--> Code Repository

## Guide to Contents

This page looks at examples from the Python module sys.

• The program args.py shows the first command-line argument being printed.
• The program allArgs.py shows all command-line arguments being printed.
• By default the recursion limit for Python is 1000 frames. The program factorial.py shows this in action.

Here is factorial.py.

#!/usr/bin/env python3
import sys
def factorial(n):
return 1 if n == 0 else n*factorial(n - 1)
sys.setrecursionlimit(10003)
n = int(sys.argv[1])
print("%s! = %s" % (n,factorial(int(sys.argv[1]))))


This works for any number up to 10,000.

 $./factorial.py 100 100! = 9332621544394415268169923885626670049071596826438162146859\ 29638952175999932299156089414639761565182862536979208272237582511\ 85210916864000000000000000000000000$