Time: 
2016-04-24 13:45-2016-04-24 14:45
Room: 
CC-235

Experience level

Learner

Session Track

Programming

Python Decorators Inception

Python decorators provide elegant power.  When you read about them, they may seem difficult: functions that wrap functions... functions that create functions that wrap functions... decorators to decorate your decorators!  This talk will walk you through the levels of decorators and provide clear examples.

Learn to write functions that create new functions, and how functions can "close over" data.  Learn how to use decorators to add logging or other side-effects to functions.  Learn how to make decorators optional, enabled or disabled at run time and costing nothing when disabled.  Gain a more complete understanding of what happens when you import a module, and how to use decorators to do things when your code is imported.  Write your own decorators.  And of course, learn how to use a decorator to decorate your decorators.