Terry Reedy wrote: > On 4/11/2015 3:19 PM, Thomas 'PointedEars' Lahn wrote: >> Terry Reedy wrote: >>> What Chris is describing is one local namespace (sheet of paper) per >>> function *call*. >> I *know* what he is describing: the *call* stack. > > My comment above was directed not at you specifically but at the OP, > Jonas, […]
ACK >> The variable $bar then keeps its last value for subsequent calls of >> foo(). > > In Python, one can do something similar with attributes, except that > attributes are easily accessible from outside the function. AISB. Python’s “attributes” are named “properties” elsewhere. > Mutable defaults probably come closer. > > def doubler(_val=[1])" > _val[0] *= 2 > return _val[0] > > print(doubler(), doubler(), doubler()) > # 2 4 8 Fascinating. Thanks. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. -- https://mail.python.org/mailman/listinfo/python-list