On Thu, 20 Jun 2013 11:05:32 -0700, Rick Johnson wrote: > Python functions are objects that take arguments, of which (the > arguments) are then converted to attributes of the function object. > Ah-Ha! Urm, but wait! We already have a method to define Objects. Heck, > I can even create my own callable objects if i want! > > Observe: > py> class FuncAdd(object): > ... def __init__(self, ivalue): > ... self.ivalue = ivalue
Notice how you are storing state here? I thought you said, and I quote: "When the subroutine is completed, ALL INPUTS and local variables are expected to be destroyed. If the programmer wants a return value, he need simply ask. Data persistence is NOT a function of subroutines!" [emphasis added] And yet here you are defining persistent input ("ivalue") to the callable subroutine, which is stored as external state and not destroyed at the end of the subroutine call: > ... def __call__(self, numeric): > ... return self.ivalue + numeric > ... All you have done here is define a subroutine with state, precisely the thing that you say subroutines must never have. What you haven't done is define a function which takes a default value that can be overridden when called. Your argument is invalid. -- Steven -- http://mail.python.org/mailman/listinfo/python-list