For the Polish people, it is the single truly optimistic thing that has happened since the end of World War II. The election of a Polish pope is unbelievable, extraordinary. But there are also some dangers."

The words are those of a Catholic teacher and intellectual in this 1,000 year-old city that is the heart-land of Polish Catholics and the home diocese of Cardinal Karol Wojtyla who will be invested today in Rome as Pope john Paul II.

Chilling rain and thick fog hang steadily over Krakow these autumn days, darkening the ancient Gothic walls of Wawel Cathedral where Wojtyla presided over mass for the past 20 years.

It is impossible, however, to dampen the pride that Poles quickly express to the outsider.

It is also impossinle, thoughtful poles say, to overstate the potential importance of unpredictable political forces set in motion in Poland and elsewhere in communist Eastern Europe by the ascendancy of a Polish Prelate to the papacy Wojtyla, who is the 264th pontiff, is the first non-Italian to occupy the throne of St. Peter in more than four centuries.

Despite an officially atheistic communist government since the end of the war, the Poles have clung to their Catholicism not only more then other Communist bloc country but perhaps more than any other country in the world.

More than 90 percent of this country's 35 million people are Catholics.For most of the postwar years they have been led by postwear years they have been led by Polish primate Cardinal Stefan Wyszynaki, 77, of Warsaw, the most fiery and politically astute defender of the faith in the East bloc since Hungary's Cardinal Josef Mindszenty died in 1975.

The situation, combined with Poland's traditional nationalism its independent-minded workers and corps of outspoken political dissidents, has made Poland unique in Eastern Europe. It is a place with rival centers of power that must be handled with extreme care by the Polish regime, led by Communist Party Edward Gierek, secretary under the watchful eye of Moscow.

Gierek is generally viewed as an honest man. Even his critics prefer him to some unknown and possibly harder-line Moscow-imposed substitute.

In recent years, Gierek has made efforts to improve church-state relations in Poland. But for the most part, this is viewed as a neccesary attempt by him to gain the church's cooperation - for as small a price as possible - to keep the lid from blowing off in a traditionally volatile country where twice in two decades worker uprising have overturned governments.

Many Poles believe Gierek has lost the ability to govern; that Poland's rival centers of power have produced something of a stalemate. That is why the stunning selection in Rome of a Pole as pope is so important.

"Psychologically, this could be the dramatic breakthrough," said one Warsaw resident. "There is a feeling that reforms are necessary. There is a lot of gloom here. But nobody really has the political power or maneuvering room. All the factions are restricted in what they they could do. But the force of what has happened now means some movement can take place and people are basically optimstic that it will be for the good."

The sudden spotlight of the whole world. East and West, on the Polish church and the situation in Poland," added a member of the dissident Workers Self-Defense Committee in Krakow, "will make it harder for the government to crack dowm" on dissident groups and unofficial self-education programs to which the church has tacitly lent some mora support.

Last year, after 1976 worker riots over proposed higher food prices, Gierek met with Cardinal Wyszynki and then traveled to Rome to meet with Pope Paul VI, both firsts for a Polish Communist Party chief.

There were hopes in Poland at the time that some response would forthcoming to church demands an easing official censorship, access by the church to the mass media, and for more churches and priests. But virtually nothing happened except some further church dissappointment.

Last month, Polish bishops, with a leading role played by Cardinal Wojtyla issued a sharply worded pastoral letter that was read in all churches condemning the continued state censorship, which it called "a weapon of totalitarian systems meant . . . meant to paralyze the cultural and religious life of the whole nation."

"Now the government is in a quandary," a Warsaw journalist said."They are not sure what to do. What has happened in Rome has nothing to do with this government. This thing has happened to the Polish people, to the Polish nation and its history."

Officially, Gierek and his government have sent expressions of great satisfaction to Rome that for the first time in history "a son of the Polish nation" will sit on the papal throne. They have also expressed hope for further improvement in relations with the Vatican.

Initially, the inherent drama of the situation is expected to push Gierek toward some concessions - Perhaps more new church construction authorizations and more training of priests, sources here say. Some things are already happening just by the flow of events.

The new pope's first mass last week in Rome was aired for about 20 minutes on Polish television, the first time anyone here can remember a mass being televised. To day's envestiture likewise is expected to be shown in part. Not to do so could be very dangerous.

A Catholic weekly newspaper in Krakow that for years has been asking for approval to double its press run, was allowed a slight one-time increase for the investiture issue, though it was only a fraction of the extra copies it had asked to pring. Although the government is allowing many Poles to travel abroad, some key figures for whom the government was not issuing passports are going to Rome because the new pope-an old friend-invited them.

"At the moment, we are probably the most democratic country in Europe," one Warsaw writer said with a grin. "Public opinion is being taken very seriously by the regime, at least on a day-to-day basis now. Whether it will last is the key question."

Within Catholic intellecual circles, nobody seems to feel that the government will ever yield in the long run on the deeper issues of censorship and legal status for the church.

One dissident suggested that Poles might become passive. "Now people might feel we have a great man on the outside and he will help us so we can sit back for a years rather than be active, he said.

That is not a widely shared view, however. Most sources believe the church will seek to press its new strength delicately but quickly.

There is another fear. "The election has given the population an incredible boost," a Krakow student said. "There is a feeling of confidence, like an umbrella over peoples' head now so that nothing bad can happen to them. But that is a native and maybe even dangerous feeling because people can become more easily annoyed and perhaps more aggressive when the government does things they don't like."

For Gierek, the new Pope solves one problem and raises others.

Wojtyla, if anything, was viewed as even tougher for a communist government to get along with than Wyszynksi. There had been government concern that the younger Wojtyla, 58, would eventually succeed Wyszynski, who was sick last year. Now Wojtyla is out of Poland but in the most important church job in the world and Gierek faces not only the unpredictable emotional situation here but also the prospect that his policy toward the Vatican may be in for rough going.

In churches circles, the Gierek policy is seen mostly as an effort to drive a wedge between the Vatican and its strongest East European outpost, the Polish church.

In recent years, Polish church leaders have had a skeptical view of Vatican Eastern policy, believing Rome was too eager to trade Soviet concessions on Catholics in Lithuania, for example, for Vatican influence to help calm the churches in Eastern Europe.

But with Wojtyla in Rome, an exprienced leader who grew up in Naziruled and then Communist-ruled Poland, most Polish churchmen believe the Vatican a more "mature" foreign policy with fewer illusions about what can be gained from the Kremlin on church matters.

How much the new pope, who now has global spiritual responsibilites, turns his attention to the East is another question. It is frequently pointed out here that the churches in Eastern Europe are the ones are filled while those in the West are frequently empty.

For Moscow, the events in Rome probably mean Gierek will be granted some more leeway to meet some new church and worker demands to help keep things cool and avoid an explosive conflict that nobody in Poland wants, because if it is bad enough it could bring a Soviet intervention.

Whether the new stature of a Polish pope will fuel outspokeness by church leaders elsewhere in the eas is uncertain. Czechoslovakia and Hungary, in particular, have large Catholic populations, though not as overhelming as Poland. But Poles point out that neither country has the temparement or recent history of church willingness to confront the state.

The most interesting reaction could be ing East Germany with its predominantly Protestant population. The Protestant Church there in recent months has taken unprecedented stands challenging the introduction of compulsory military training for teenagers in state schools. It also has spoken out against signs of anti-Semitism in East Germany and warned the Communist authorities to stop trying to pin all the blame for pre-war fasicism against West Germany because it runs the danger of failing to recongnize it when appears again in the East.

On a train heading toward Warsaw, a retired Polish army officer asked to borrow an American reporter's copy of the International Herald Tribune. He nodded his head in agreement with Western news accounts of public Polish pride and private governmental concern here in Moscow.

"Everybody is very proud," he said, "even the nonbelievers. Even the Communists are enjoying being Polish for a few days.

"But the situation is extraordinary. The government has been going one way for a long time now and the people are going another way. This will make it even more so. It will strengthen the church even more- make it harder for both the church and the government to keep things under control. The economics situation is still very bad. The shortages are still here and the people are not in a very good mood."

The former officer paused for a while and then said he believes "a new era is starting now. It was started by your President Carter when he first began talking about human rights. It takes a few years to see but it is starting. The election of Cardinal Wojtyla is part of it. Something is happening and no one knows when it will lead.