Principal open sets of affine schemes This question is a special case of Open subschemes of affine schemes are affine? where it is established that in general, open subschemes of affine schemes are not affine. I was wondering if this was true in a more specific case, i.e. for principal opens. Take an affine scheme $X= Spec A$. My guess would be that for any $f\in A$ $$ (D(f), \mathcal O_{X\vert D(f)})=(Spec A_f,\mathcal O_{Spec A_f})$$ as ringed spaces. To do this I would use the natural map $$\pi: A\rightarrow A_f$$ to construct maps $$\phi:D(f)\rightarrow Spec A_f$$ $$\psi: Spec A_f\rightarrow D(f)$$  with $\phi:\mathfrak p \mapsto (\pi(\mathfrak p))$, the ideal generated by $\pi(\mathfrak p)$, and $\psi: \mathfrak q\mapsto \pi^{-1}(\mathfrak q\cap \pi(A)) $. Would this work? Is there a simpler way? 
 A: Considering the map $\pi$ is the right idea. Recall (or try prove) the following lemma.  

$\textbf{Lemma:}$ Let $f\colon A\to B$ be a ring homomorphism. Then the continuous map on the spectra $F=\operatorname{Spec}f$ can be extended to a map of schemes $(F,F^\sharp)\colon \operatorname{Spec}B\to \operatorname{Spec}A$ such that on the principal open sets of $\operatorname{Spec}B$ $F^\sharp$ is just the map making the square involving $f$ and the localization maps commute.

So, in this situation we obtain a map of schemes $(F,F^\sharp)\colon \operatorname{Spec}A_f \to \operatorname{Spec}A$, where $F=\operatorname{Spec}\pi$. Clearly, the image of $F$ is contained in, and in fact equal to, the principal open $D(f)$. So $(F,F^\sharp)$ restricts to map of schemes $G=(F',F'^\sharp)\colon \operatorname{Spec}A_f \to (D(f),\mathcal{O}_{\operatorname{Spec}A\vert{D(f)}})$.
We wish to prove that $G$ is an isomorphism. On the topological level that's clearly the case. To see it's an isomorphism on the level of sheaves, it's enough to check this on a basis. A basis for the topology on $D(f)$ is given by the principal opens of $\operatorname{Spec}A$ which are contained in $D(f)$, i.e. those of the form $D(fg)$. Now, as mentioned above, $F'^\sharp_{D(fg)}$ is just the map $A_{fg}\to (A_f)_{(g/1)}$ making the diagram involving $\pi$ and the localization maps $A\to A_{fg}$ and $A_f \to (A_f)_{(g/1)}$ commute, and this is an isomorphism.
