This question is inspired by this question.
Let $f\colon S_1\rightarrow S_2$ for some topological spaces $S_1,S_2$. Suppose that for every $x_0\in S_1$ there exists an open set $U\subset S_1$, such that $\forall x\in U, f(x)=f(x_0)$.
What are the sufficient and necessary conditions on $S_1$, that $f$ is constant?
As shown in the previous question:
Necessary conditions are: $S_1$ is connected
Sufficient condition: $S_1$ is pathconnected