# In Sage, how to extract coefficient of a polynomial in a ring

For instance, $f=x^2y^2+1$ is an element of $\mathbb{C}[x,y]$, I want to extract the coefficient of $x^2$, which is $y^2$. However "f.coefficient(x,2)" only works for symbolic expressions, are there similar functions for ring elements?

-
I don't know anything about Sage, but perhaps you could tell it to find $\dfrac{1}{2}\dfrac{\partial^2 f}{\partial x^2}(0,y)$? –  Jonas Meyer Jun 30 '12 at 7:51
By the way, there ask.sagemath.org for sage. In case you have more specific questions in the future. –  Jernej Jun 30 '12 at 8:59
Simply use f.coefficient(x^2), as in this example:
sage: R.<x,y> = CC[]