On 22/09/2011 08:45, Eric Snow wrote:
A recent thread on the python-ideas list got me thinking about the
possibility of a static statement (akin to global and nonlocal). I am
wondering if an implementation would have to address thread safety
concerns.
I would expect that static variables would
On Thu, Sep 22, 2011 at 6:16 PM, Eric Snow wrote:
> That's a good point. So, isn't the default arguments hack in the same
> boat with regards to threads?
>
> Maybe I'm just misunderstanding the thread concept in Python. Threads
> have separate execution stacks but share interpreter global state,
On Thu, Sep 22, 2011 at 2:06 AM, Chris Angelico wrote:
> On Thu, Sep 22, 2011 at 5:45 PM, Eric Snow
> wrote:
>> I would expect that static variables would work pretty much the same
>> way as default arguments
>
> Could you just abuse default arguments to accomplish this?
>
> def accumulate(n,sta
On Thu, Sep 22, 2011 at 5:45 PM, Eric Snow wrote:
> I would expect that static variables would work pretty much the same
> way as default arguments
Could you just abuse default arguments to accomplish this?
def accumulate(n,statics={'sum':0}):
statics['sum']+=n
return statics['sum']
>>>