Function Interfaces and Callback-Based Code : Interface : Class PYTHON TUTORIALS


PYTHON TUTORIALS » Class » Interface »

 

Function Interfaces and Callback-Based Code


class Callback:
    def __init__(self, color):            
        self.color = color
    def __call__(self):                   
        print 'turn', self.color

cb1 = Callback('blue')                    
cb2 = Callback('green')

cb1(  )                                   
cb2(  )                                   


cb3 = (lambda color='red': 'turn ' + color
print cb3(  )



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Class
» Interface