Built-in Functions and Types
staticmethod()
Wrap a callable so that attribute access through a class or instance does not inject self or cls. Use it for a function related to the class’s purpose that needs neither instance nor class state. The descriptor preserves the underlying callable on normal lookup. Unlike a classmethod, inherited static methods do not receive the subclass automatically.
Formal Syntax & Structure
python syntaxpython
staticmethod(function, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| function | callable | Callable to expose without implicit binding. |
Return Value
staticmethod
Descriptor that returns the wrapped callable on attribute access.
Working Example
Example Snippetpython
class Units: @staticmethod def meters_to_cm(meters): return meters * 100
print(Units.meters_to_cm(2.5))print(Units().meters_to_cm(1))