VIVAHATE

January 2010

Python Decorators

class decoratorWithoutArgs(object):
    def __init__(self, fn):
        self.fn = fn

    def __call__(self, *args):
        self.fn(*args)

class decoratorWithArgs(object):
    def __init__(self, arg):
        self.arg = arg

    def __call__(self, f):
        def wrapped(*args):
            f(*args)
        return wrapped

@decoratorWithoutArgs
def foo():
    pass

@decoratorWithArgs(10)
def bar():
    pass

if __name__ == "__main__":
    foo()
    bar()

Nyx 0.0.1

Nyx is a Python ctypes binding to a simple OpenGL rendering library written in C.

Example