Confessions of a Python fanboy

Chris Rebert clp2 at rebertia.com
Fri Jul 31 10:38:16 CEST 2009


On Fri, Jul 31, 2009 at 1:31 AM, Xavier Ho<contact at xavierho.com> wrote:
> On Fri, Jul 31, 2009 at 6:25 PM, Chris Rebert <clp2 at rebertia.com> wrote:
>>
>> I believe "full" anonymous functions was intended by the author.
>> lambdas are limited to a single expression. "Full" anonymous functions
>> would be allowed to contain multiple statements.
>>
> Cheers, but what about this:
>
>  def goBig(x):
>     while True:
>         x = x ** 2
>         yield x
>
> for result in goBig(10):
>     if result > 10 ** 100:
>         break
>     print result
>
> It's a silly example, but wouldn't goBig(10) in this example be a "full
> anonymous function"?

No, because it has a name, namely "goBig"; this obviously prevents it
from being "anonymous".

For comparison, note how the function in the following example is
never given a name, and is thus anonymous:
>>> (lambda x: x+5)(6)
11

Cheers,
Chris
-- 
http://blog.rebertia.com



More information about the Python-list mailing list