Base Class to Support Method Decorators

AUTHOR:

  • Martin Albrecht (2009-05): inspired by a conversation with and code by Mike Hansen

class sage.misc.method_decorator.MethodDecorator(f)[source]

Bases: SageObject

EXAMPLES:

sage: from sage.misc.method_decorator import MethodDecorator
sage: class Foo:
....:     @MethodDecorator
....:     def bar(self, x):
....:         return x**2
sage: J = Foo()
sage: J.bar
<sage.misc.method_decorator.MethodDecorator object at ...>
>>> from sage.all import *
>>> from sage.misc.method_decorator import MethodDecorator
>>> class Foo:
...     @MethodDecorator
...     def bar(self, x):
...         return x**Integer(2)
>>> J = Foo()
>>> J.bar
<sage.misc.method_decorator.MethodDecorator object at ...>
from sage.misc.method_decorator import MethodDecorator
class Foo:
    @MethodDecorator
    def bar(self, x):
        return x**2
J = Foo()
J.bar