NYC schools opened their doors to students last week after a summer in which city officials celebrated improved state test scores.

But even as he touted traditional public schools’ higher scores, Mayor Bill de Blasio has been quick to dismiss the stronger test scores from the city’s charter schools, especially those run by Success Academy.

He can’t have it both ways. De Blasio may be right to applaud the marked improvements in scores across the city, though it’s also hard to do a comparison when the tests and test conditions were very different this year from years past. But in the mayor’s ongoing fight with Success Academy, it’s petty and shortsighted of him to say charter schools’ success isn’t equally laudable.

The numbers say a lot. Charter schools boasted a 43 percent pass rate for English Language Arts exams in 2016, compared with 38 percent for traditional public schools.

De Blasio suggests that the charter schools’ scores were unimportant and attributed them to extensive “test prep.” But plenty of traditional public schools do the rote preparation de Blasio criticized, from sending home packets of sample test questions to practicing test conditions in the classroom in the weeks before the exams. And de Blasio himself has said the scores are significant signs of how well city schools are doing.

And then there’s the question of what exactly is test prep. In the right curriculum, students should be taught the material they’ll find on the exams — from solving problems to reading for understanding. If they’re taught well and given guidelines for how to take tests, that, too, is test prep, but not something to deride. There are ways to go beyond drilling and homework packets.

As the school year begins, perhaps city officials and school administrators can focus on meaningful ways to teach the curriculum and prepare students for test-taking. But test prep alone doesn’t explain charter schools’ scores. There are some new ideas and best practices from charters that city schools can implement. If de Blasio looked more closely, and didn’t automatically dismiss the successes of others, perhaps he’d learn something new.