0

I'm just starting to learn about Python class and static methods. I don't know how Python static methods differ from other languages' static methods, so I don't know if the answer to my question maybe already exists somewhere else on a question pertaining to another language.

It seems to me that Python static methods are useful only as a way to put a set of functions into a namespace, to "containerize" them. Are there any other uses for them that aren't at least equally well accomplished by just having a separate function or by having a class/instance method?

2
  • 1
    "It seems to me that Python static methods are useful only as a way to put a set of functions into a namespace" -> Yup, that's it exactly. Any function that logically occupies the same functional space as a class, but isn't instance-specific and doesn't need a reference to the class itself to do its job is a useful thing to staticmethod. Commented Jan 10, 2019 at 23:07
  • I almost never use them. Only once or twice where the namespacing was really critical, mostly where I see it being very useful for code-completion. Other than that, I almost always prefer module-level functions Commented Jan 11, 2019 at 0:11

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.