Twice within the past few years, I have been pulled over by the police for driving at night without my headlights on. My car is supposed to turn on the headlights automatically when the light outside is below a certain level, but sometimes I accidentally brush against the controls and inadvertently switch them to manual.

Both times I thanked the policeman because he may well have saved my life. Neither time did I get a ticket or even a warning. In each case, the policeman was white.

Recently a well-known black journalist told me of a very different experience. He happened to be riding along in a police car driven by a white policeman. Ahead of them was a car driving at night with no headlights on and, in the dark, it was impossible to see who was driving it.

When the policeman pulled the car over, a black driver got out and, when the policeman told him that he was driving without his lights on, the driver said, "You only pulled me over because I am black!"

This was said even though he saw the black man who was with the policeman. The driver got a ticket.

Later, when the journalist asked the cop how often he got such responses from black drivers, the reply was "About 80 percent of the time."

When the same journalist asked the same question of black cops, the answer was about 30 percent of the time — lower, but still an amazing percentage under the circumstances.

Various black "leaders" and supposed friends of blacks have in recent years been pushing the idea that "driving while black" is enough to get the cops to pull you over for one flimsy reason or another.

Heather Mac Donald of the Manhattan Institute wrote a book titled "Are Cops Racist?" which examined the empirical evidence behind similar claims.

The evidence did not support the claims that had been widely publicized in the media. But her study was largely ignored by the media. Maybe it would have spoiled their stories.

Even before reading Mac Donald's book, I found it hard to accept the sweeping claims about the dangers of "driving while black."

Looking back over a long life, I could think of a number of times that I had been pulled over by the police in a number of states, without any of the things happening that are supposed to happen when you are "driving while black."

Nor could I recall any member of my family who had told me of any such experiences with the police. It was hard to believe that we had all just led charmed lives all these years.

Only about half the times that I was pulled over did I end up being given a ticket. Once a policeman who pulled me over and asked for my driver's license said wearily, "Mr. Sowell, would you mind paying some attention to these stop signs, so that I don't have to write you a ticket?"

Recently I pulled off to the side of a highway to take a picture of the beautiful bay below, in Pacifica, Calif. After I had finished and was starting to pack up my equipment, a police car pulled off to the side of the highway behind me.

"What's going on here?" the policeman asked.

"Photography," I said.

"You are not allowed to park here," he said. "It's dangerous."

"All right," I said, "I am packing to leave right now."

"Incidentally," he said as he turned to get back in his car, "You can get a better view of the bay from up on Roberts Road."

I then drove up on Roberts Road and, sure enough, got a better view of the bay. And I didn't get a ticket or a warning.

In a world where young blacks, especially, are bombarded with claims that they are being unfairly targeted by police, and where a general attitude of belligerence is being promoted literally in word and song, it is hard not to wonder whether some people's responses to policemen do not have something to do with the policemen's responses to them.

Neither the police nor people in any other occupation always do what is right, but automatic belligerence is not the answer.

Thomas Sowell is a senior fellow at the Hoover Institution, Stanford University.