@@ -182,9 +182,9 @@ are always available. They are listed here in alphabetical order.
182182 base 16). :exc: `ValueError ` will be raised if *i * is outside that range.
183183
184184
185- .. function :: classmethod(function)
185+ .. decorator :: classmethod
186186
187- Return a class method for * function * .
187+ Transform a method into a class method .
188188
189189 A class method receives the class as implicit first argument, just like an
190190 instance method receives the instance. To declare a class method, use this
@@ -1384,9 +1384,9 @@ are always available. They are listed here in alphabetical order.
13841384
13851385 For sorting examples and a brief sorting tutorial, see :ref: `sortinghowto `.
13861386
1387- .. function :: staticmethod(function)
1387+ .. decorator :: staticmethod
13881388
1389- Return a static method for * function * .
1389+ Transform a method into a static method .
13901390
13911391 A static method does not receive an implicit first argument. To declare a static
13921392 method, use this idiom::
@@ -1405,12 +1405,21 @@ are always available. They are listed here in alphabetical order.
14051405 :func: `classmethod ` for a variant that is useful for creating alternate class
14061406 constructors.
14071407
1408+ Like all decorators, it is also possible to call ``staticmethod `` as
1409+ a regular function and do something with its result. This is needed
1410+ in some cases where you need a reference to a function from a class
1411+ body and you want to avoid the automatic transformation to instance
1412+ method. For these cases, use this idiom:
1413+
1414+ class C:
1415+ builtin_open = staticmethod(open)
1416+
14081417 For more information on static methods, consult the documentation on the
14091418 standard type hierarchy in :ref: `types `.
14101419
1411- .. index ::
1412- single: string; str() (built-in function)
14131420
1421+ .. index ::
1422+ single: string; str() (built-in function)
14141423
14151424.. _func-str :
14161425.. class :: str(object='')
0 commit comments