Page 102 -
P. 102

faulty default


          Your API is still not right


          Although the API lets your users invoke the function in its original form, the
           nesting is switched on by default. This behavior is not required by everyone and
           some people aren’t at all happy.
                                         Another
                                     version of “nester” has                     I can’t believe it! My
                                     been released...but its                  programs were back to running
                                     default behavior might not               fine, but now everything is
                                       be what you want.                       indented. Has this thing
                                                                               changed again?!?




                     Funny...it works fine
                     for me.






























           Of course, if you have some functionality that really ought to be optional
           (that is, not the default), you should adjust your code to make it so. But how?

           One solution is to add a third argument which is set to True when the
           indenting is required and False otherwise. If you ensure that this argument
           is False by default, the original functonality becomes the default behavior
           and users of your code have to request the new indenting feature explicitly.


           Let’s look at adding this final revision.

           66    Chapter 2
   97   98   99   100   101   102   103   104   105   106   107