[Python-ideas] Long Live PEP 3150 (was: Re: Statement local functions and classes (aka PEP 3150 is dead, say 'Hi!' to PEP 403))

Arnaud Delobelle arnodel at gmail.com
Mon Oct 17 16:57:58 CEST 2011


On 17 October 2011 12:56, Paul Moore <p.f.moore at gmail.com> wrote:

> I still like the idea in principle, but I'm no longer sure it's as
> useful in practice as I'd expected. A really good use case would help
> a lot (Nick's argparse example is a start, but I'm nervous about the
> idea of writing an API that relies on out of order evaluation to be
> readable).

Note that, if the "given" keyword creates a new scope, it provides a
way to give static variables to functions - a feature for which
various ad-hoc syntaxes were recently discussed on this list:

counter = counter given:
    acc = 0
    def counter(i):
        nonlocal acc
        acc += i
        return acc

-- 
Arnaud



More information about the Python-ideas mailing list