What Is The Use Of @staticmethod ?

Posted by One-Type-2842@reddit | Python | View on Reddit | 31 comments

I run examples to understand @staticmethod, but I end up found no more usefulness of this decorator

```

# In a class Pizza:

@staticmethod

def get_size_in_inches(size):

"""Returns the diameter in inches for common pizza sizes."""

size_map = {

"small": 8,

"large": 16,

}

return size_map.get(size, "Unknown size")

```

```

# In a class Pizza:

def get_size_in_inches(self, size):

"""Returns the diameter in inches for common pizza sizes."""

size_map = {

"small": 8,

"large": 16,

}

return size_map.get(size, "Unknown size")

```

Both of the above methods are similar to access.

Someone Explain me what is the use of @staticmethod then?

Is it a type hint of editors or related to compiler?