def partial_bell(n, k):
#Sage names the variables x0, x1, ...; this database writes them
#x1, x2, ... as the notation has them.
p = bell_polynomial(n, k)
R = PolynomialRing(ZZ, ['x%d' % (i + 1) for i in range(n - k + 1)])
return R(p.subs({g: R.gen(i) for i, g in enumerate(p.parent().gens())}))
partial_bell(17, 8) # past the end of this table