Functor (closure)

Functors are objects that can be called like a function. They are typically used as callback functions. And they typically remember some value making the act as a closure.

#!/usr/bin/env python

class doSomethingWithAnInt(object):
    def __init__( self, i):
        self.i = i
    def __call__( self):
        print( "frozen ", self.i)


a = doSomethingWithAnInt(3)

a()