A Python Book
1.6.7 continue and break statements.......................................................................48
1.6.8 try: except: statement.....................................................................................49
1.6.9 raise statement...............................................................................................51
1.6.10 with: statement.............................................................................................52
1.6.10.1 Writing a context manager...................................................................52
1.6.10.2 Using the with: statement....................................................................53
1.6.11 del................................................................................................................54
1.6.12 case statement..............................................................................................55
1.7 Functions, Modules, Packages, and Debugging....................................................55
1.7.1 Functions.......................................................................................................55
1.7.1.1 The def statement...................................................................................55
1.7.1.2 Returning values....................................................................................55
1.7.1.3 Parameters..............................................................................................56
1.7.1.4 Arguments..............................................................................................56
1.7.1.5 Local variables.......................................................................................57
1.7.1.6 Other things to know about functions....................................................57
1.7.1.7 Global variables and the global statement.............................................58
1.7.1.8 Doc strings for functions.......................................................................60
1.7.1.9 Decorators for functions........................................................................60
1.7.2 lambda...........................................................................................................61
1.7.3 Iterators and generators.................................................................................62
1.7.4 Modules.........................................................................................................67
1.7.4.1 Doc strings for modules.........................................................................68
1.7.5 Packages........................................................................................................68
1.8 Classes...................................................................................................................69
1.8.1 A simple class................................................................................................69
1.8.2 Defining methods..........................................................................................70
1.8.3 The constructor..............................................................................................70
1.8.4 Member variables..........................................................................................70
1.8.5 Calling methods.............................................................................................71
1.8.6 Adding inheritance........................................................................................71
1.8.7 Class variables...............................................................................................72
1.8.8 Class methods and static methods.................................................................72
1.8.9 Properties.......................................................................................................74
1.8.10 Interfaces.....................................................................................................75
1.8.11 New-style classes.........................................................................................75
1.8.12 Doc strings for classes.................................................................................77
1.8.13 Private members..........................................................................................77
1.9 Special Tasks.........................................................................................................77
1.9.1 Debugging tools.............................................................................................77
Page 4