[Python-ideas] Before and after the colon in funciton defs.

Nick Coghlan ncoghlan at gmail.com
Fri Sep 23 06:03:27 CEST 2011

On Fri, Sep 23, 2011 at 11:11 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> With this spelling, the above would be roughly equivalent to:
>    def outer():
>        i = i
>        def f(x):
>            return x + i
>        return f
>    f = outer()

Alex Gaynor pointed out the above would give an unbound local error.
The actual rough equivalent would be more like:

   def outer(i=i):
       def f(x):
           return x + i
       return f
   f = outer()


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list