When is a morphism of $k$-ringed spaces the morphism induced by pullbacks? Let $(X, O_X)$ and $(Y,O_Y)$ be $k$-ringed spaces ($k$ a field), and let $(f,P)$ be a morphism between them. When is the case that $P: (O_Y(U)) \to O_X(f^{-1}(U))$ is given by precomposition with $f$? I  know this is true for affine algebraic varieties, and it was suggested to me that it was true for other spaces too. I would appreciate it if someone could provide a reference. I am especially interested in the case of real or complex manifolds.
By a morphism of $k$ ringed spaces, I mean a continuous map $f$ along with a pullback map taking the sections of $U \subset Y$ to the sections of $f^{-1}(U)$ that commutes with the restriction maps in the appropriate way.
 A: It's true for real and complex manifolds (viewed as locally ringed spaces over $\mathrm{Spec}(\mathbf{R})$ and $\mathrm{Spec}(\mathbf{C})$, respectively, with morphisms $\mathrm{Spec}(\mathbf{R})$ and $\mathrm{Spec}(\mathbf{C})$-morphisms of locally ringed spaces). First note that the definition ensures that all the residue fields are either the real or complex field, according as you are in the smooth or holomorphic case. This allows you to view your ring of global sections as actual functions (the value at a point is the image of the section in the residue field at the point). The rest follows ultimately from the fact that the maps on local rings are local homomorphisms (and induce the identity on residue fields).
Note that this is not true, and simply makes no sense, for schemes over general fields (even over an algebraically closed field $k$, you can only view the global sections as $k$-valued functions upon restricting to closed points, which more or less puts you in the classical setting). 
