[Python-ideas] nonlocal functions

Carl Johnson cmjohnson.mailinglist at gmail.com
Wed Oct 21 12:03:39 CEST 2009


2009/10/20 Masklinn:

> def foo():
>    let a = 1
>    let b = 3
>    def bar():
>        a = 2
>        let b = 4
>    bar()
>    return  (a, b) # returns (2, 3)

This is all fantasy, but what is your proposal when this happens:

def foo():
   let a = 1
   stuff
   stuff
   let a = 2 #Oops, forgot about already declaring it!

I also imagine that you won't allow a bare "let a"? Or does it just
set itself to None?

— Carl



More information about the Python-ideas mailing list