So, it would seem there’s an unspoken rule about methods that would, strictly, have underscores in them but don’t. There’s nothing in PEP8 about this.
Examples:
random.lognormvariate str.removeprefix
I’m guessing the thought process is that it’s okay as long as the name is still understandable. But, what’s wrong with log_norm_variate or remove_prefix? Is saving those one or two extra characters really worth it?
It’d be nice if the core maintainers could chime in what they consider acceptable for dropping the underscore (not that I mean to bikeshed).
Not a core dev, but I’d attribute this to 3 things:
older names tend to have fewer underscores
if the rest of the module doesn’t have underscores, underscores in new
names are jarring
not everything needs an underscore (it’s more of a guideline)
str.removeprefix is actually pretty new, but the other string methods do
not use underscores and nobody wanted an underscored name duringn the
PEP discussion as I recall.