THE CANDIDATES FOR GOVERNOR in Virginia, Democrat Terry McAuliffe and Republican Attorney General Ken Cuccinelli II, have spent the past couple of weeks mocking each other as flip-flop artists. They’re both right, and Virginia voters have good cause to be happy about it.

Mr. Cuccinelli flipped on relaxing Virginia’s standards for restoring voting rights to ex-convicts, which until now have been among the most restrictive in the nation. As a state senator, he bitterly opposed allowing felons to regain the vote after serving their sentences, even those convicted for some marijuana offenses. “So this is what [Democrats] think they need to do to win?” he said, saying that registering former “jailbirds” to vote was “ominous.”

Now it turns out that it’s not so ominous for Mr. Cuccinelli who, as a gubernatorial candidate, has been trying to moderate his image. Last week, he backed an important shift by Gov. Robert F. McDonnell, who decreed that, from now on, most nonviolent felons would regain their voting rights more or less automatically upon the completion of their sentence.

Mr. McAuliffe flopped on drilling for oil off Virginia’s coast, which he opposed on environmental and other grounds when he pursued the Democratic nomination for governor in 2009. Now, having “learned more about offshore drilling from experts in Virginia,” he favors it, a spokesman said last month.

Both candidates had political cover in executing their 180s, as each was falling in line with his party’s political superiors. Mr. Cuccinelli was lining up with the man he hopes to succeed, Mr. McDonnell, a fellow Republican. Mr. McAuliffe was aligning himself with the state’s most prominent Democrats, Sens. Mark Warner and Timothy M. Kaine.

In the process, each was doing what politicians do when they run for office: making themselves more electable by spurning some of their own party’s core supporters and appealing to swing voters who, especially in centrist Virginia, tend to determine outcomes. In Mr. Cuccinelli’s case, that means partisan Republicans who recoil at the prospect of felons, including African Americans, who vote heavily for Democrats, regaining the vote. In Mr. McAuliffe’s, it means hard-core environmentalists who tend to downplay the country’s energy needs and play up the risks.

Neither shift would mean much in practical terms for a number of years. The state has not located many of the felons who might be eligible to regain the vote under Mr. McDonnell’s new policy — nor are there funds budgeted to find them. As for offshore drilling and the revenue it might one day produce for the state, who knows? There is little hard or recent evidence of substantial oil deposits off Virginia’s coast.

Still, notwithstanding the scorn each candidate has heaped on the other, Virginians are the winners in the flip-flop contest. Sensing that the electorate has little tolerance for extreme positions, both candidates are sidling to saner ones, at least on some issues. Not the worst aspect of democracy.