Generalize continuity from compact subsets to the whole domain space I saw a statement on http://en.wikipedia.org/wiki/Metric_space#Continuous_maps:

f is continuous if and only if it is continuous on every compact subset of M1.

It is stated for the case that f is a mapping between two metric spaces.
I was wondering if the statement is true for mappings between general topological spaces?
Why?
Thanks and regards!

More questions:
What makes the statement true for a mapping between two metric spaces? Can you give a sketch for the proof?
 A: Let $X$ be a topological space.
Then $X$ has the property that a function $f:X\to Y$
(where $Y$ is an abritrary topological space) is continuous if
its restriction to each compact subspace is continuous if and only if
$X$ is compactly generated topological space.
The space $X$ is compactly generated if a subset $A$ whose intersection
with any compact subspace $K$ of $X$ is open in $K$, is open in $X$.
Most familiar topological spaces are compactly generated
(Euclidean spaces, manifolds, CW-complexes etc.) but not all;
see Qiaochu's answer for an example.
A: The statement is false in general.  Let $X$ be an uncountable set with the cocountable topology.  Then all the countable subsets of $X$ have the discrete topology and are therefore closed but not compact, so the only compact subsets of $X$ are the finite subsets, which also carry the discrete topology.  It follows that every function $X \to Y$, where $Y$ is any topological space, is continuous on compact subsets of $X$.  (But, for example, if $Y$ has the same underlying set with the discrete topology, the "identity" function $X \to Y$ is not continuous.)
Edit:  In response to your second question, the property you are looking at is equivalent to being compactly generated.  A topological space $X$ is compactly generated if it satisfies the following condition: a subset of $X$ is open if and only if its intersection with every compact subset is open.  
So why are metric spaces compactly generated?  Recall that a space is first-countable if every point has a countable neighborhood basis.  Metric spaces are first-countable because at any point the sequence of open balls of radius $\frac{1}{n}, n \in \mathbb{N}$ forms a countable neighborhood basis.  And first-countable spaces are always compactly generated; see the proof here.
A: show that a subset of a metric space X is  closed iff its intersection with every compact subset of X is closed
