If President Trump succeeds in moving the Supreme Court to the right, it could turn out to be the best thing to have happened to the Democrats in years.

This line of thinking was nicely articulated the other day by The New York Times’ David Leonhardt in a column urging liberals not to despair. Leonhardt didn’t go so far as to suggest that a right-wing court would be the “best” thing in years. He did, though, urge a course of realism and a new strategy for pursuing liberal policies.

Like, say, winning elections.

“Over the last half-century, conservatives have put more energy into building a movement,” Leonhardt wrote. Above all, he added, “winning local, state and congressional elections.”

Democrats, meanwhile, “have emphasized higher-profile politics, like the presidency and landmark court cases.” Leonhardt suggested Democrats “can’t afford to do so anymore.”

Those strike me as wise words as we stand at the brink of what might yet come to be called the Trump court. And they are words to mark for the conservative caucus, too.

After all, we were there once.

I will never forget arriving at the editorial page of The Wall Street Journal in the summer of 1980. One of the first assignments I drew was to go to Washington to meet an obscure freshman congressman.

His name was Newt Gingrich. He had the crazy idea that it would be possible for the GOP to win control of the House. It seemed fantastic, hard even to imagine.

That’s because, save for two terms, the GOP hadn’t controlled either the House or Senate in 50 years. It would take Gingrich 14 years to craft his Contract With America that, in 1994, helped win the House.

In the generation since, Democrats have controlled the House for only two terms. Liberals have counted on the Supreme Court to ram through their policies and programs.

Beginning in the 1960s, liberals have won from the Supreme Court such victories as, to name but a few, birth control, abortion and same-sex marriage. And more power to them.

It’s not my purpose to belittle those victories. Even Justice Potter Stewart, dissenting in the case that ended Connecticut’s curb on birth control, thought the Nutmeg State’s law was “uncommonly silly.”

But relying on the court to overturn the popular will as expressed through legislated law has costs. It generates a resentment that has been, to judge by the last election, way underestimated by the left.

Which is where Leonhardt’s lesson comes in. He reckons Trump’s nominee (Brett Kavanaugh, as it turned out) is “overwhelmingly likely” to be seated on the high bench.

Hence the logic of turning to — forgive my coarse language — politics. Leonhardt thinks liberals should focus on elections at all levels, local, state and national.

That strategy puts a retrograde cast on Elizabeth Warren’s prediction that the battle to replace Justice Anthony Kennedy would be the “fight of our lives.” And on Chuck Schumer’s vow to oppose Kavanaugh with “everything I’ve got.” That, after all, wouldn’t leave much left for the House, Senate and local races ahead.

Leonhardt is by no means the only liberal advising the Democrats to look to the legislatures. Justin Levitt of USA Today calls the sudden focus on elections a “bright side” to the Kavanaugh nomination.

“It is unhealthy to have the country’s political aspirations so dependent on the personality and policy priors of one man in a robe,” Levitt writes. He adds that it doesn’t really matter who the judge is.

It’s nice to hear such talk from the left. Even if the Journal, The Post and other conservative commentators and strategists have been banging this drum for years.

It’s always possible, of course, that the Democrats will regain Congress or one of its houses in a matter of months. That would only underline the point about politics.

Meantime, it seems there’s nothing like losing the Supreme Court to focus the attention in politics. Nor a more apt moment for the expression “here comes the judge.”