I have been reading Luciano Ramalho’s Fluent Python, and in the book he says he cannot think of a good use for staticmethod, I have been thinking about that, and so far I have only thought of one good use case: when you have a version of a common function, e.g., sum, and you want to qualify it with a better name but something like sumLineItems would sound wrong (to me at least). Would this be a good choice for something like:
class LineItem: . . . . . . . . def __add__(self, other):
### Function body ### . . . . . . . . @staticmethod def sum(items: Sequence[LineItem]) -> LineItem: ### Add up LineItems ###
Does this seem like a reasonable use for staticmethod? I think its a good way to qualify a name in a more concise way.
Thanks, Ed M.