Let $X$ be a scheme. I am doing an exercise: Let $p \in X$. Describe a canonical (choice-free) morphism from \operatorname{Spec} \mathcal{O} \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, \mathcal{O}_X)$, we have image of $y$ in $\mathcal{O}_{X,p}$, $y_p = [(y, X)]_p$, and this defines a ring homomorphism from $\Gamma (X, \mathcal{O}_X)$ to $\mathcal{O}_{X,p}$. By the correspondence, this gives a morphism of schemes $\operatorname{Spec} \mathcal{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 \mathcal{O}_{X,p}$ to denote the element of stalk at $p$, given by $f \in \Gamma(U, \mathcal{O}_X)$.
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$.