The evocative term “baggy-pants comic” has its roots in burlesque, but you could apply it with some justice to the new documentary film “When Comedy Went to School,” which opens on July 31 in New York City and Aug. 2 on Long Island. The film, directed by Mevlut Akkaya and Ron Frank, tells the story of the Catskills hotels as a training ground for stand-up comedians and, like the burlesque funny man’s trousers, it’s rather shapeless. But, like the guy inside the trousers, it is also very funny.

The Borscht Belt was an almost unique phenomenon in American entertainment. With the exception of the African-American vaudeville and night club circuits, the product of racial segregation, the Catskills hotels and bungalow colonies that made up what Lawrence Richards’ script calls “the largest resort area in the United States” were an ethnic entertainment enclave unlike any other, a paradise for Jewish-American families for several generations and more than 50 years.

Richards traces the history of the hotel industry in the area with both affection and intelligence, although his script is frequently verbose and more than a little sentimental. (Narrator Robert Klein’s gently edgy tone helps undercut its worst excesses.) Given the sociological and historical forces that shaped the development of Jewish summer life in the Catskills, it would be hard to tell any of this story without a lot of explanation, and the filmmakers’ use of several local Jewish academics is astute. Dr. Robert Shain is a particularly lucky find, a professor of history who was a social director at one of the hotels when he was younger.

The list of comics who are interviewed for the film is every bit as impressive: Jerry Lewis, Sid Caesar, Jackie Mason, Jerry Stiller, Mort Sahl, Dick Gregory and the late Mickey Freeman. Any one of these guys would be worth a film of his own.

Which is where the film trips over its own baggy pants. Lewis, Caesar, Sahl and Mason are all very, very smart men who have real insight into the way that the Catskills functioned as a training ground for comics, and they offer thoughtful and reasonable insight into the way that on-the-job education in the Catskills influenced comedy across the board. But there is simply too much material here for the film to display coherently.

“When Comedy Went to School” wants to be a history of the Borscht Belt, of the rising social status of the Jewish-American community post-World War II, of the evolution of entertainment in the mass media age, of the mechanics of stand-up and of the lives of a dozen different performers ranging from Danny Kaye (ex-tummler turned world ambassador) to comics-turned-filmmakers like Lewis, Billy Crystal, Mel Brooks and Woody Allen. And in the midst of all this highly intelligent deep thinking, the filmmakers want to squeeze in a wealth of clips from films and television.

It’s all worth doing. It’s all worth doing well. But it would take a long mini-series to make it all fit and to do justice to the subject matter. To pack it into a 77-minute running time, and frame it with cheesy recreations — well, you’d need a lot of film cutters to deal with the overflow.

And yet … Thanks in no small part to Klein and the outstanding library of comedy clips that Akkaya, Frank and Richards drew on, “When Comedy Went to School” is still a lot of fun. The insights are sprinkled throughout like nicely gooey chocolate chips and the laughs come pretty frequently.

“When Comedy Went to School” opens on Wednesday, July 31 at the IFC Center (323 Sixth Ave.) and Friday, Aug. 2 at the Malverne Cinema (350 Hempstead Ave., Malverne) and the Kew Gardens Cinema (81-05 Lefferts Boulevard, Queens). There will also be a special screening at and at the JCC in Manhattan (Amsterdam Avenue and 76th St.) on Wednesday, July 31 at 8:15 p.m. with a Q&A with the filmmakers and several comedians.