Early this week, the writers’ coalition, PEN America, sued President Trump in federal court.

Trump “has made eminently clear his disdain for the press and the legal protections the First Amendment affords it,” the lawsuit said. It recalled Trump’s view “that it is ‘frankly disgusting the way the press is able to write whatever they want to write’ and that ‘people should look into that.’ ”

PEN wants the court to block the president from using his office to retaliate against media criticism. The suit cites Trump’s reported meddling in the proposed merger of AT&T and CNN and his reported pressuring of the U.S. postmaster general to double Amazon’s postal rates. (Amazon founder Jeffrey P. Bezos owns The Washington Post.)

But the same president who calls the media disgusting — and thinks it would be a good idea “loosen up” libel laws so plaintiffs can win lots of money — would be lost without free-speech protections.

Yes, our trash-talking president needs the First Amendment like a marathon runner needs his water bottle. He would collapse without it.

Proof came this week when Stormy Daniels lost her defamation claim against Trump and was told to pay his legal fees. It was a stinging defeat for the porn actress — all thanks to laws that are based on free-speech protections.

She had objected to a Trump tweet that, in essence, called her a liar. But Judge S. James Otero wasn’t having it.

“The court agrees with Mr. Trump’s argument because the tweet in question constitutes ‘rhetorical hyperbole’ normally associated with politics and public discourse in the United States,” he wrote.

“The First Amendment protects this type of rhetorical statement.”

The president, of course, celebrated the victory with more of the same — by referring to Daniels as “horseface” in a new tweet. (And she, in turn, well . . . never mind.)

But that’s not all.

Just over a week ago, lawyers for the Trump campaign moved to dismiss a different suit — this one over WikiLeaks’ publication of Democratic National Committee emails.

Two donors and one former DNC employee are claiming that the Trump campaign violated their privacy by working with Russia and WikiLeaks to publish hacked emails.

The campaign’s lawyers reached for — guess what? — the First Amendment, making the case that the right to free speech supersedes the right to privacy.

The First Amendment leaves people “free to obtain information from diverse sources in order to determine how to cast their votes,” their motion said.

Natasha Bertrand, writing in the Atlantic, called the campaign’s arguments timely and troubling.

“The midterm elections, less than 30 days away, are as vulnerable to hackers who steal information and then dump it onto the web to influence voters as the presidential election was two years ago,” she wrote.

But the Trump way is eminently practical: Whatever works.

That seems to be the thinking in both of these cases, and in Trump’s continued verbal assault on the media — the far-reaching effects of which may well, if indirectly, include the Saudi government’s apparent belief that they could get away with the suspected killing of Washington Post contributing columnist Jamal Khashoggi.

“Do one thing and say another. Different rules apply to me” is how Daniels’ lawyer, Michael Avenatti, described to me how Trump operates in the free-speech arena.

(Avenatti pushed back against the declaration by Trump’s lawyer, Charles Harder, that Daniels had suffered “total defeat.” The main case — over whether hush money paid to her broke campaign-finance law — proceeds apace.)

And, he said, he never took seriously the president’s threats to try to change the libel laws: “It’s just another weapon against the press, part of his whole fake-news strategy.”

New York Times deputy general counsel David McCraw told me by email Wednesday that Trump seemed to realize, when he came to the Times shortly after his election, that he shouldn’t try to turn bluster into reality.

Asked about the libel laws in that meeting, Trump said: “Actually, someone said to me on that, they said, ‘You know, it’s a great idea softening up those laws, but you may get sued a lot more.’ I said: ‘You know, you’re right. I never thought about that.’ I said, ‘You know, I have to start thinking about that.’ ”

As McCraw put it: “He is thoroughly taking advantage of all the protections of the press he has spoken out against.”

Defamation and libel are hard to prove in the United States, as Stormy Daniels found out. And that’s a good thing: Within limits, the country thrives on free expression.

Trump knows this, whatever he may say to the contrary.

As he blasts, daily, far beyond civility into the ugly territory of insult and threat, he is well aware that the laws he disses are very likely to protect him.