Even the vice-presidential picks are similar: the Democrat picks a Washington veteran as his vice presidential candidate to add foreign policy expertise to the ticket, while the Republican selects a staunchly conservative governor to shore up the base.  Certainly some of the parallels are coincidental. It is unlikely, for example, that the writers knew Mr. Obama had an affection for Bob Dylan when they made Santos a Dylan fan. But it is the unintentional similarities that make the DVDs of the sixth and seventh seasons, which at the time received mixed reviews, so rewarding to watch now. In both “The West Wing” and in real life, for example, the Phillies played in the World Series during the election campaign.  As the primaries unfolded this year, “I saw the similarities right away,” said Lawrence O’Donnell, a producer and writer for the series who has appeared on MSNBC as a political analyst. Mr. O’Donnell had used Mr. McCain as one of the templates for the Vinick character in the episodes he wrote, though he said that “McCain’s resemblance to the Vinick character was much stronger in 2000 than in 2008.”  Echoing the criticism Mr. McCain faced during the primaries, a White House aide in “The West Wing” contends that Vinick is “not conservative enough” for the Republican base. Sometimes the two candidates’ situations are almost identical: when the press starts asking where Vinick attends church, he tells his staff that “I haven’t gone to church for a while.” Asked in July by The New York Times about the frequency of his church attendance, Mr. McCain said, “Not as often as I should.”  Mr. Alda and Mr. McCain are the same age. When a hard-edged strategist played by Janeane Garofalo joins the Santos campaign, she immediately alludes to Vinick’s age. “He’s been in the Senate for like 90 years. He was practically born in a committee room,” she says.  In the same way that Obama surrogates have subtly knocked Mr. McCain’s lack of computer skills, the Garofalo character remarks to the Santos campaign manager, Josh Lyman: “Why are you always talking about high-tech jobs? Because Vinick uses a manual typewriter.”  Conversely, Santos staffers talk about getting video of the candidate with his “adorable young children hugging their hale and vital dad.” The casting of Mr. Smits introduced story lines about the prospect of a minority president. But when an aide suggests a fund-raising drive in a Latino community, Santos snaps: “I don’t want to just be the brown candidate. I want to be the American candidate.” The Obama campaign has made similar assertions.  Still, “The West Wing” — like Mr. Obama — does not ignore racial issues entirely. In the seventh season Santos delivers a speech on race at a critical moment for his campaign, and staffers privately worry that voters will lie about their willingness to vote for a minority candidate.  If the show sometimes seems like a political fantasy — a real debate where politicians are required to answer questions? a candidate rejecting an attack ad? — it also reflects the tenor of the real-life campaign season.  Santos wins the nomination only after a lengthy fight on the convention floor, an inexact parallel to Obama’s extended primary fight with Senator Hillary Rodham Clinton. Just as the Obama campaign pivoted to the economy this fall, Lyman tells Santos staffers that “this new economic message may be our ticket,” and he winds up being right. An economic crisis does not ensue, but back-to-back emergencies on “The West Wing” — a nuclear power plant malfunction and a dispute in Kazakhstan — bring to mind the election-defining qualities of the actual economic crisis.  “Dramatically, they are exactly the same thing: the unforseeable,” Mr. O’Donnell said.  As President Bush did during the bailout talks, Jed Bartlet, the Democratic “West Wing” president played by Martin Sheen, brings both candidates to the White House for a briefing. Facing the prospect of deploying 150,000 American soldiers to Kazakhstan three weeks before the election, Vinick grumbles, “I can say goodbye to my tax cut.” He tells Santos, “Your education plan’s certainly off the table.”  Santos emerges victorious weeks later, but only after a grueling election night. Online, some “West Wing” fans are wondering whether the show will wind up forecasting the real-life result as well. In Britain, where the series remains popular in syndication, a recent headline on a blog carried by the newspaper The Telegraph declared: “Barack Obama will win: It’s all in ‘The West Wing.’ ”  A version of this article appears in print on , on page C1 of the New York edition with the headline: Following the Script: Obama, McCain and ‘The West Wing’. Order Reprints| Today's Paper|Subscribe
Parallels between the final two seasons of “The West Wing,” which ended its run in May 2006, and the current political season are unmistakable.