TITLE: On a canonical morphism from Spec $O_{X,p} \rightarrow X$
QUESTION [6 upvotes]: Let $X$ be a scheme. I am doing an exercise: Let $p \in X$. 
Describe a canonical (choice-free) morphism from Spec $O_{X,p} \rightarrow X$, with 
hint that says to make sure that the morphism is independent of choice.
This is what I thought:
Given any $y \in \Gamma (X, O_X)$, we have image of $y$ in $O_{X,p}$, $y_p = [(y, X)]_p$, and this defines a ring homomorphism from $\Gamma (X, O_X)$ to $O_{X,p}$. By the correspondence, this gives a morphism of schemes $Spec \ O_{X,p} \rightarrow X$.
I thought this was right, but I haven't done anything to make sure it is independent of choice. I just don't see what I am missing... I would appreciate any assistance!
PS I denoted $[(f, U)]_p \in O_{X,p}$ to denote the element of stalk at $p$, given by 
$f \in \Gamma(U, O_X)$.

REPLY [9 votes]: This is not right. The adjunction between spec and global sections goes the other way:
$$\hom(X, \text{spec}(A)) = \hom(A, \Gamma(X, \mathcal O_X)).$$
What you should do is this: Choose an open affine $U = \text{spec}(A)$ containing $p$. Then there is a map $\Gamma(U, \mathcal O_X) \to \mathcal O_{X, p}$, hence a map $\text{spec } {\mathcal O_{X,p}} \to U.$ Composing with the inclusion $U \to X$, we get a morphism  $\text{spec } {\mathcal O_{X,p}} \to X$. Show that this morphism is independent of the choice of $U$.