[Python-ideas] Tweaking closures and lexical scoping to include the function being defined

Carl Matthew Johnson cmjohnson.mailinglist at gmail.com
Wed Sep 28 12:14:13 CEST 2011


On Sep 27, 2011, at 11:59 PM, Nick Coghlan wrote:
> 
>    def accumulator():
>        def incr(x) [tally=0]:
>            tally += x
>            return tally
>        return incr


Brackets feel too much like line noise… A keyword?

def incr(x) and rebind 0 as tally: ?
def incr(x) with static tally = 0: ?


Just tossing out ideas…


More information about the Python-ideas mailing list