French commentators today interpreted the expulsion of 47 alleged Soviet spies as a political master stroke by President Francois Mitterrand that has discomfited his political rivals on both the left and the right and strengthened his reputation abroad.

The Socialist government has presented the mass expulsion as a response to growing Soviet espionage activities in France during the past decade. In the phrase of the government spokesman, Max Gallo, the decision to expel the Soviets was taken to show that France was not "a soft underbelly" of Europe for the theft of military and technological secrets.

"Even though espionage has become current practice, it is also a rule that he who is caught must be punished," Gallo told reporters following a regular weekly Cabinet meeting.

While few political analysts here doubt that the Soviet Embassy was engaged in extensive espionage operations, the fact remains that no hard evidence has yet been produced by the French authorities to explain why such spectacular measures had to be taken now. The conclusion drawn by many commentators is that the timing of the operation was dictated by a careful appraisal by Mitterrand of the political costs and benefits that were likely to flow from it.

An editorial in the independent leftist daily, Liberation, which broke the news of the expulsions yesterday morning, said the risks included a further cooling in relations with Moscow.

This could result in disruptive activity by pro-Moscow elements in the French Communist Party and Communist-dominated CGT trade union federation at a time when the country is bracing itself for economic hard times.

On the other side of the political equation, the paper cited the boost to Mitterrand's credentials as an "Atlanticist" just a few weeks before the summit of western industrialized nations at Williamsburg, Va. It will now be that much easier for the French leader to brush aside American complaints about technology transfers to the Soviet Union or continued unease with the presence of Communists in the government.

To this can be added the domestic political benefits that flow from what the French public is likely to perceive as firm government and the forceful assertion of national interests. The most recent public opinion polls show a sharp drop in the popularity of Mitterrand and his prime minister, Pierre Mauroy, following a setback in municipal elections in March and the implementation of austerity measures.

Liberation pointed out that the spy affair could have favorable financial repercussions at a time when France was finding it difficult to get fresh capital.

U.S. officials today went out of their way to emphasize that the French government acted entirely on its own initiative and not as a result of any prodding by Washington. Informed sources have said that the U.S. Embassy here was told of the impending expulsions last Thursday through "routine channels" shortly after the Soviets learned of it.

The beauty of Mitterrand's move, from his point of view, is that it is very difficult for any of his political rivals to criticize it without appearing to be unpatriotic. The opposition parties on the right, including the Gaullists, have the delicate task of explaining why they did not take equally vigorous measures during their time in power, while the Communists do not want to be seen as apologists for Moscow.

The Communists have reacted to the dilemma by attempting to ignore it. The official party newspaper, L'Humanite, devoted only a brief news story to the expulsions--concentrating mainly on the Soviet protest--with the terse comment that the French action "unfortunately risks a serious deterioration in the climate of relations" between Paris and Moscow.

Interviewed in Greece, where he is on a working official visit, the Communist Party leader, Georges Marchais, said that the incident would certainly not mean his party's withdrawal from the government. This comment has confirmed the widespread belief here that the Communists will swallow virtually any humiliation from the Socialists in order to cling to a share of power, as the alternative is even swifter electoral decline.

Political figures on the right, meanwhile, have been reduced to the kind of grudging praise uttered by a former Gaullist interior minister, Raymond Marcellin, who said: "47 spies, that's fine, but there are hundreds of them." He added that, when he was a minister in the early 1970s, he had wanted to expel 150 Soviet diplomats, but his wish had been turned down by the government. The Gaullists traditionally have sought good relations with Moscow.