Counterpart of Weierstrass theorem  Assume that $(X,\tau)$ is a topological space and assume that every continuous mapping $f$ of $X$ into real line $\mathbb{R}$ achieves its maximum. Under which conditions on $\tau$, the space $X$ is compact. It can be easily prove that, $X$ is compact, provided that $\tau$ is a metric topology in $X$. 
Is for example this true for the Hausdorff spaces?
 A: You look for the notion of a pseudocompact space. 
A: In this answer, I will assume that all spaces are Hausdorff.
It is well known that a space is compact if and only if it is pseudocompact and realcompact[See The Stone Cech Compactification by Russel Walker p.34]. A space is realcompact if and only if it can be embedded in $\mathbb{R}^{I}$ as a closed subspace. Also, in the topology book by Dugundji, the author proves that a space is compact if and only if it is countably compact and metacompact. Here metacompact means that every open covering has a point-finite open refinement (A cover $\mathcal{U}$ of $X$ is point finite if $\{U\in\mathcal{U}|x\in U\}$ is finite for each $x\in X$). In particular, a space is compact if and only if it is pseudocompact and metacompact. Since Metrizable implies paracompact implies metacompact, every pseudocompact metrizable space is compact.
For an easy example of a completely regular pseudocompact space that is not compact try the set $\omega_{1}$ of all countable ordinals. In fact, it can easily be shown that every continuous map $f:\omega_{1}\rightarrow\mathbb{R}$ is eventially constant.
A: Any countably compact space $X$ has this property. The image of a continuous real valued function of $X$ is a countably compact subset of $\mathbb{R}$, hence compact because it is Lindelöf, so it has maximum and minimum.
