“IF MEN were angels,” James Madison wrote, “no government would be necessary.” President Obama, who has tried to govern this country for the past eight years, is no exception to Madison’s realistic assessment of human nature. We have had our differences with Mr. Obama from time to time. However, it bears notice — emphasis, really — that in the days since what can only be described as a traumatic election result for Mr. Obama and his party, as well as a critical moment for the entire world, the president has led his country with magnificent dignity.

This is no matter of mere optics. The Founders firmly believed a republic could not long survive without civility, tolerance and grace. Madison, again: “To suppose that any form of government will secure liberty or happiness without any virtue in the people is a chimerical idea.” It would be equally chimerical to suppose that a people could become virtuous unless its leaders model virtue, especially in difficult times, which is why the Founders united behind George Washington, the epitome of virtue in his day, as the first president.

And modeling virtue is precisely what Mr. Obama has been doing. To a divided nation, both electoral halves of which were still undoubtedly stunned at what had transpired, the president preached unity and understanding, with evident sincerity, not a trace of rancor, and in terms that were plain but free of condescension: “We have to remember that we’re actually all on one team. This is an intramural scrimmage. We’re not Democrats first. We’re not Republicans first. We are Americans first. We’re patriots first. We all want what’s best for this country.”

He magnanimously praised President-elect Donald Trump for his own temperate concession speech. That is to say, he rose above the ugly insults — “born in Kenya”; “founder of ISIS” — that Mr. Trump had hurled at him. And, implicitly, the president rose above the shots he himself had taken, on the campaign trail. Mr. Obama endeavored instead to remind people that there is life, a whole world of it, beyond this turn of events, and indeed beyond politics itself, through which we must all travel with “a sense of unity; a sense of inclusion; a respect for our institutions, our way of life, rule of law; and a respect for each other.” Mr. Obama carried himself with the same grace, and with the same calming focus, while meeting with Mr. Trump at the White House, and as he addressed a Veterans Day audience for the last time as president.

Haters gonna hate, as the song says; and we express these thoughts fully cognizant that there are some Americans so committed to loathing this president that they will not appreciate how he has just embodied republican virtue before their very eyes. For everyone else, including non-Obamahaters who nonetheless voted for Mr. Trump, Barack Obama has provided an example of conduct under pressure worthy of close study and, we hope, emulation.