Not long after three police officers were shot dead Sunday in Baton Rouge, La., President Obama condemned the attack. "For the second time in two weeks, police officers who put their lives on the line for ours every day were doing their job when they were killed in a cowardly and reprehensible assault," he said. "These are attacks on public servants, on the rule of law, and on civilized society, and they have to stop."

But Obama's support for the police has not always been taken at face value. Last week, he confronted more skeptical questions about his support for police officers at a town hall in Washington. Police officers "know you support law enforcement, of course," Texas Lt. Gov. Dan Patrick, a Republican, told Obama during the event, which aired on ABC and ESPN. "But do they really in their heart feel like you’re doing everything you can to protect their lives?" Patrick added. "Words matter. Your words matter much more than mine. Everything you say matters."

Patrick was only the most recent conservative politician to argue that Obama has not supported law enforcement the way that he should. "The last couple of years, Barack Obama has done nothing but hate on cops, accusing cops of being bad and racist," former congressman Joe Walsh (R-Ill.) said on CNN.

Obama has raised deep questions about police shootings of unarmed black men and made a few criticisms of law enforcement. He has pointed, for instance, to evidence that police are more likely to pull over black drivers in the absence of a clear violation of traffic laws, among other broad disparities in the criminal-justice system.

In acknowledging these shortcomings, though, Obama has always spoken highly of America's police. In doing so, he has also offered several detailed arguments for the importance of law enforcement during his presidency.

Most police are not bad people

For example, Obama rebuked advocates for police reform in his speech at a memorial for the five officers killed in Dallas last week. Sometimes, he said, these activists wrongly blame entire police forces for the bad actions of a few.

Barack Obama delivered remarks July 12 at an interfaith memorial service in Dallas for the five police officers killed by a sniper July 7. (Reuters)

"The overwhelming majority of police officers do an incredibly hard and dangerous job fairly and professionally," Obama said. "When anyone, no matter how good their intentions may be, paints all police as biased or bigoted, we undermine those officers we depend on for our safety."

Studies of complaints about officers' behavior filed by citizens support Obama's argument.

In 1991, an independent commission established to study the Los Angeles Police Department after the beating of Rodney King found that just 183 of the department's 8,500 officers were the subject of at least four allegations of excessive force or improper tactics. The commission faulted superior officers for failing to discipline this small group.

Last month, two criminologists published a study of complaints filed by citizens in eight cities: Albuquerque; Charlotte; Colorado Springs; Columbus; Fort Wayne, Ind.; Knoxville, Tenn.; Portland, Ore.; and St. Petersburg, Fla. Their study also found that a small group of officers accounted for a disproportionate number of complaints -- 79 percent of officers were the subject of one complaint at most. Officers who generated more complaints tended to be younger and less experienced.

In Chicago, an analysis by FiveThirtyEight found that the most complaints were filed against just 22 percent of officers who were the subject of any complaint. Because many officers were not the subject of any complaints and were not included in this calculation, these figures suggest that a large majority of officers in Chicago get along well with civilians.

Overall, the research does suggest there might be a systemic failure in some departments to address civilians' concerns and punish those officers who use excessive force. At the same time, the data also supports Obama's argument about how most individual officers act day to day.

Police maintain the rule of law

From the president's point of view, police provide an important public service, one that, like many other public services, was long denied in black neighborhoods.

"Historically, in fact, the African American community oftentimes was underpoliced rather than overpoliced," Obama said at the NAACP National Convention last year. "Folks were very interested in containing the African American community so it couldn’t leave segregated areas, but within those areas there wasn’t enough police presence."

Obama might have been referring to the work of 20th-century anthropologists such as Hortense Powdermaker. While the authorities routinely ignored lynchings and other violence perpetrated by white Southerners against their black neighbors, Powdermaker also found that Southern law enforcement did not investigate violent crimes among African Americans.

In other words, the police made less of an effort to seek justice for black victims of crime, regardless of the race of the perpetrator.

"Our entire way of life in America depends on the rule of law," Obama said in Dallas last week. "The maintenance of that law is a hard and daily labor."

Police are cost-effective

In May, Obama's economic advisers issued a report that discussed the value of police work, presenting evidence that the country needs more officers.

The report argued that by preventing crime, police bring a range of benefits to the places where they work. Those benefits exceed the costs of hiring and equipping officers in economic terms, according to the report.

The authors of the document cited research on legislation that President Bill Clinton signed in 1994. The law included a number of controversial aspects, but it also dedicated federal resources to employing tens of thousands of police officers in local agencies. The research suggests those new officers significantly reduced the number of major crimes in the places where they were hired.

The report from the White House estimates that spending an additional $10 billion to pay and equip more police officers would reduce the number of crimes nationwide each year by as much as 1.5 million. The economic benefits of those avoided crimes would total about $38 billion, according to the report.

The president and his aides have been careful to acknowledge widespread concerns about whether police are adequately respectful of civilians' civil rights. Obama has also pointed out that there is still evidence of racial biases in criminal justice, even if those biases are not always the fault of individual officers. All the same, his rhetoric has been frustrating for critics of U.S. law enforcement.

"At this moment, I just think it’s tone-deaf to say we need more cops," Paul Butler, a legal scholar at Georgetown University, said when the report was published. "The recommendation to increase the number of police is blind to history, and it’s blind to the present moment."