A record number of people have applied to join the French police force over the past year. Many new recruits say the recent attacks in Paris inspired them to sign up. It also seems that the shootings have made the country rethink its attitude towards the police.

A young recruit pushes away a woman charging at her with a club. The recruit draws her revolver. "Police! Don't move!" she yells.

Audrey is taking part in a self-defence class at the police training school in Sens, eastern France, having signed up after gunmen attacked the satirical magazine Charlie Hebdo and a Jewish supermarket at the start of 2015.

"Since the [Paris] terror attacks in January and November last year, the danger confronting us is clear," she says. "Any one of us can be a victim. Every one of us needs protection. And we all want to help somehow. That's why I'm here. To help make this country safer."

In March this year, a record 35,000 people sat the exam to join the police - 50% more than last year.

Only 8% of those who took the test passed - the same success level as for the entrance exam for the elite Science-Po political science school in Paris.

Image caption Recruits taking part in firearms training

"I was really shocked by the video from the Charlie Hebdo killings of the policeman who was on the ground, asking for mercy, who they shot in cold blood," says another recruit, Perez, when I ask him why he joined the police.

I think these young people are discovering a sense of duty and the desire to help their fellow human beings Jacques Richard, Director of police training college

"That made me want to defend our republic, defend our nation even more. In the morning we'll wake up and know that maybe today we'll risk our lives but we're more motivated than ever," he says.

The policeman Perez is talking about was called Ahmed Merabet, and the next recruit I talk to shares the same first name.

"I'm of Algerian origin," he says. "We had a lot of terrorism in Algeria when I was growing up. I remember the curfews when we went there on holiday. When the Bataclan happened in November I remembered Algeria, and in December I joined the police."

Three of the victims in the Charlie Hebdo and kosher supermarket attacks were police officers, and the live TV coverage of their colleagues storming the shop to save hostages led many to see them as heroes.

Image copyright Getty Images Image caption French special forces storm the Hyper Cacher building in January 2015

Then, in November, the first man to confront the attackers inside the Bataclan concert hall in Paris was an off-duty police officer who happened to be passing. He entered the building and shot one of the gunmen dead with his service revolver. A few days later police stormed a flat in St Denis, just north of the city, killing the suspected ringleader.

"The terror attacks are a decisive factor for many in our new intake," says the director of the training college, Jacques Richard.

"I think these young people are discovering a sense of duty and the desire to help their fellow human beings.

"When something like this happens, people pull together. Everyone wants to make their own contribution. There's been a big increase in the number of people volunteering to give blood, for example. And more people have wanted to join the emergency services and the police. It's had a big influence on the way people think."

Image copyright EPA Image caption Policeman Ahmed Merabet was shot outside the Charlie Hebdo offices

The image of the police in France has changed significantly over the past 20 years. The 1995 film La Haine, a hit both at the box-office and with the critics, portrayed the police as sadistic and racist.

"It's an anti-police film," explained Mathieu Kassovitz, who won the best director prize for the movie at Cannes that year. When the cast climbed the famous festival steps, the police on duty there turned their backs in protest.

The police have had an extremely negative image in France for centuries, says historian Jean-Marc Berliere, who's written several books about them.

"Even in Louis XIV's time the people loathed the police," he says. "In the public imagination the police meant repression and the limitation of freedom."

Image copyright AFP Image caption Protestors clashed with police outside the Sorbonne in 1968

A defining moment was May 1968 when police and rioting students fought pitched battles around Paris's Sorbonne University. That revolutionary movement spread to workers bringing the French economy to a virtual standstill for two weeks. Violence erupted when President Charles de Gaulle tried to sort things out by sending in the police.

I couldn't believe it - here was a young, urban, intellectual crowd applauding the police Jean-Marc Berliere, Historian

But the media always had a soft-spot for the paving-stone-hurling students.

But four days after the Charlie Hebdo massacre, something extraordinary happened. People filled the streets of Paris to show their sympathy for the the victims and demonstrate their support for the police. A video posted on YouTube captures the moment.

The crowd parts. There are women running - some of them laughing. "What's going on?" says the man filming with his smartphone. And then, police - in vans and on foot. Their black rubber shoulder protection giving them the kind of silhouettes usually associated with science fiction heroes. And the crowd starts to chant, "Merci, merci" - Thank you, thank you.

Image copyright Alamy Image caption Demonstrators applaud police officers escorting families and relatives of the victims

"I couldn't believe it," says Jean-Marc Berliere who was there. "Here was a young, urban, intellectual crowd applauding the police! I saw women giving them flowers. I saw people shaking their hands. I saw women kissing them. And you could see how moved the police were. It was so unexpected."

For Audrey, it made her realise that "this job is, in fact, fantastic".

Something like this had happened only once before, says Berliere, at the liberation of Paris in August 1944. The police were the first to rise up against the Germans before the Allies got there. "Afterwards, when they marched, the crowds shouted 'Vive les flics!' - Long live the cops!" he says.

It's not clear if the police's popularity will last, or if it will sag like a souffle in a police canteen.

A video of a police officer hitting a young black demonstrator at a recent demonstration against labour reforms has not helped their image. Neither has a book by renowned anthropologist Didier Fassin, La Force de l'Ordre (Security Forces). He was allowed to follow the police in one part of the Paris region from 2005 to 2007 and reports widespread brutality and racism.

But, for the time being at least, a significant part of the French population is seeing the police in a new way. As heroes.

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.