### polynomials of derivative operator

Is there any way in Sage to evaluate expressions such as
p(x^2*d/dx + a + x - x^2*y) 1
where p() is a polynomial in one variable? The result would be a polynomial in a,x, and y.

Alternatively, can Sage evaluate
(1/f) p(d/dx) f
where f is a (non-polynomial) function of x and a and y?

Thanks very much.