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

Hans Nowak wurmy at earthlink.net
Mon Aug 5 23:12:13 EDT 2002


Bryan Olson wrote:

> Contrary to popular belief, lambda did not add anoymous functions to
> Python.  Python had them even without lambda.
> 
> def define_twice():
>     def _twice(x):
>         return x + x
>     return _twice
> 
> print define_twice()(17)
> 
> The above code passes 17 to a function which is not bound to any name.

Really?

 >>> def define_twice():
	def _twice(x):
		return x + x
	return _twice

 >>> define_twice()
<function _twice at 0x00935678>

 >>> define_twice().func_name
'_twice'


-- 
Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA=='))
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/




More information about the Python-list mailing list