Draft Pep (was: Re: Let's Talk About Lambda Functions!)

Tim Peters tim.one at comcast.net
Mon Aug 5 19:01:51 CEST 2002


[Bryan Olson, reading a lot into

    def define_twice():
       def _twice(x):
           return x + x
       return _twice
    print define_twice()(17)
]

> Check the rules on local variables.  The function was, at one
> time, bound to the name _twice.  Nevertheless, the above code
> passes 17 to a function that is not bound to any name.

Nevertheless, it "has a name" (namely "_twice"), as you can see by doing

    print define_twice().__name__

and that's very helpful in tracebacks:

    print define_twice()({1: 2})





More information about the Python-list mailing list