Why could it be considered rep whoring to ask a question that you already know the answer to and then answer it yourself? Doing this adds to the value of the "knowledge base", and may help others when the question appears in web searches. And if the question and/or answer are good enough to get upvotes, why shouldn't the same person get points for both?
(The source of this question is John Millikin's comment on this StackOverflow question: How do I mock an open used in a with statement (using the Mock framework in Python)?.)