Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Added that "g" has to be measurable, which we never said, but we wanted. If g need not be measurable then the conditions on the space X become much weaker, on the other hand. Also, swapped order of the last two paragraphs and added necessary condition of completeness to the Kuratowski comment.
Fixed typo "supose" => "suppose" and added parenthetical (remark) about the sufficiency of separability and completeness, since this raises the question as to whether there's a Borel mapping if X is merely metrizable, which is the setting of Kuratowski.
(sorry. adding logic to prevent someone making the same mistake i did, which now appears as a comment below. if someone could add a comment that I now agree this is a counterexample, I'd appreciate that!)