A few words about the political integrity of John McCain.

Integrity was, of course, the byword of the Arizona senator, who died of brain cancer Saturday. The trait was most famously displayed in a POW camp in Hanoi when his captors, hoping for a propaganda bonanza from this son and grandson of four-star admirals, offered him his freedom. McCain refused, choosing instead to endure the same beatings, deprivation and brutality as other men whose fathers were not Navy royalty.

Donald Trump, whose bone spurs kept him out of Vietnam, once said McCain was no hero. But if he wasn’t, then the word has no meaning.

Then the hero went to Washington. And things got complicated.

Because as it turns out, political integrity and integrity are not synonymous. Indeed, some might call the former an oxymoron — like “jumbo shrimp,” or “Microsoft Works,” a term that contradicts itself. Political integrity is what happens when actual integrity collides with the compromises, expediencies and hold-your-nose deal-making governance demands.

McCain, a cantankerous, straight-talking Republican, often managed that collision with remarkable courage and moral clarity. His willingness to stand against his own party on issues like immigration and torture are the stuff of legend. But there were also times he tried to have it both ways, to satisfy both politics and integrity and ended up mangling both.

Consider his second run for the presidency and that defining moment when he took the microphone back from a woman at a town hall meeting after she said she didn’t trust his opponent, Barack Obama, because Obama was “an Arab.”

“No, ma’am,” said McCain. “He’s a decent family man and citizen that I just happen to have disagreements with on fundamental issues, and that’s what this campaign is all about.”

McCain’s refusal to be party to such intolerance spoke well of him. But that judgment is tempered by the fact that he chose as his running mate Alaska Gov. Sarah Palin, who had no such scruples about fanning the flames of intolerance, painting Obama as a scary Other and accusing him of liking to “pal around” with terrorists.

Moreover, in bringing to the national stage this incurious, ineloquent and inept woman and vouching that she was ready to lead the nation, McCain implicitly demeaned the presidency, mainstreaming the notion that the job did not require fancy credentials, knowledge of the world or even evidence of serious thought. There is a direct line from there to the 2016 election of the disaster that walks like a man, Trump.

McCain was too honest not to have known this. Yet he was also too decent to throw Palin under the bus. In his final memoir, “The Restless Wave,” he blames himself for her stumbling performance.

Which was a very McCain thing to do. Most of us can only imagine the difficulty of balancing politics and integrity. McCain likely managed it as well as anyone ever could. In a posthumous statement he said, “I have made mistakes, but I hope my love for America will be weighed favorably against them.”

It will be, especially in light of the shabby political landscape he leaves behind. Even as McCain died, after all, Trump was fulminating against aides who “flipped” on him, sounding less like the president of the United States than like Tony Soprano, ranting in the back room of the Bada Bing strip club. It was a seedy display that, paradoxically, drew into sharp focus all that we lose in losing John McCain.

Granted, political integrity is not perfect. But it sure beats no integrity at all.