It was the last leg of a long flight from Washington, D.C., and on the final approach to SFO, San Francisco glittered in the light of a March day. It’s beautiful from the air. But coming back to San Francisco after a few days in another city is always a bit of a shock.

You look at the city with fresh eyes, and it’s a jolt. Coming into downtown San Francisco you realize that the heart of the city is dirty; there is trash everywhere, and beggars, too.

You notice the windows on the BART train look like they haven’t been washed since Obama was president. The escalator at the Powell Station is out of order. It was broken when you left town, and it’s been broken for at least a month. You have to hoof it up the long stairway, and once on the street you notice homeless men just hanging around. There’s a guy sprawled sleeping in the bus stop at Fifth and Mission streets. People have to step around him to get on the bus.

It’s remarkable how the 1874 Old Mint resembles federal buildings of the same vintage in Washington. But the Mission Street side of San Francisco’s Old Mint has graffiti scrawled on it; it’s been there for two months. You don’t see that in Washington.

We were in the nation’s capital because my companion, the Sailor Girl, went to a conference. I tagged along to keep her company.

A trip to Washington is always an education. It’s a beautiful city, laid out to show the power and glory of the United States. We wandered around like tourists: saw the Lincoln Memorial, walked the great National Mall, peeked over the fence at the White House, poked around in Georgetown, had a drink and dinner at the Old Ebbitt Grill, Washington’s oldest saloon.

You are reminded of the government every day: the flags, the solemn buildings, the memorials. We talked to a man from Kentucky at the Vietnam War Memorial. He was there, he said, to honor his cousin, who was 19 years old when he was killed in a minefield back in 1975. He would have been nearing retirement age now.

There was a great commotion one evening on Dupont Circle — sirens, motorcycle cops, flashing red and blue lights, a phalanx of Secret Service cars, a black limousine flying a flag followed by more security, even an ambulance. A great man passing by like an emperor.

A big storm brushed by the city when we were there. Winds so strong planes couldn’t land at National Airport just across the Potomac. An old tree planted in Andrew Jackson’s time toppled over and wrecked a parked car. There was a snow flurry, and end-of-winter cold. Schoolkids wore big coats, like little bears.

Washington is in chaos, in the news anyway. It’s on television and in the papers, so it must be true. High officials are quitting, the administration is a mess. But the chaos must all be inside those impressive government buildings. On the outside, the city looks good. Despite the storm, the streets were clean; the fallen branches were taken away the next day. The trash bins and news racks that were blown over by the wind were quickly put right. Life went on.

I rode the Washington Metro subway a bit, too. In my salad days I used to cover BART for the newspaper, so I knew the Washington system was similar. The Metro had big mechanical and safety problems a couple of years ago. The problems were hard to see last week. The stations were clean, and so were the cars. The passengers didn’t put their feet on the seats, and I didn’t see any sleeping derelicts on the train or in the stations. The escalators all ran.

But Washington can be a tough place, too. I remember being in the wrong part of town a few years ago. A man came up to me. “Pardon me,” he said, “but you don’t belong here.” He gave me a hard look. “You should leave.” And I did.

There are panhandlers in Washington, but not many. And if there were crazy people, they were not out on the streets, screaming.

They were giving out free food the other afternoon in downtown Washington to people down on their luck. They had a line, like a cafeteria, free dinner on cardboard trays.

The customers stood by the side eating the free food, and when they were finished put the trays and the empty milk cartons in trash cans.

That was the big difference. In San Francisco, they would have thrown the garbage in the street. People treat the streets in San Francisco as if the place was a dump. Because it is.

I was puzzled by all this. How could this city work so well, while San Francisco, which is so rich and so pleased with itself, be such a mess? I asked around. “It’s the culture,” people said. “We don’t act the way you say they do in San Francisco. It’s not done.”

Maybe they take pride in their city.