Top

grizzled.decorators module

This module contains various Python decorators.

Functions

def deprecated(

since=None, message=None)

Decorator for marking a function deprecated. Generates a warning on standard output if the function is called.

Usage:

from grizzled.decorators import deprecated

class MyClass(object):

    @deprecated()
    def oldMethod(self):
        pass

Given the above declaration, the following code will cause a warning to be printed (though the method call will otherwise succeed):

obj = MyClass()
obj.oldMethod()

You may also specify a since argument, used to display a deprecation message with a version stamp (e.g., 'deprecated since ...'):

from grizzled.decorators import deprecated

class MyClass(object):

    @deprecated(since='1.2')
    def oldMethod(self):
        pass

Parameters

  • since (str): version stamp, or None for none
  • message (str): optional additional message to print

def unimplemented(

func)

Decorator for marking a function or method unimplemented. Throws a NotImplementedError if called.

Usage:

from grizzled.decorators import unimplemented

class ReadOnlyDict(dict):

    @unimplemented
    def __setitem__(self, key, value):
        pass