parameterized functions: a question of style

Blair Hall b.hall at irl.cri.nz
Mon Aug 12 18:56:47 EDT 2002


Andrew,

I agree, but my example was hypothetical (I didn't want to write a
complicated
function definition, when a simple one can illustrate the point -- that's why
I wrote
'(just for arguments sake)' ).

Would you have made that suggestion if I had written a 15-line function
parameterized on say another function and a constant?

Andrew Koenig wrote:

> Blair> def gen_fn(n):
> Blair>     def _fn(x):
> Blair>         return x**n
>
> Blair>     return _fn
>
> Why not just write
>
>         def gen_fn(n):
>                 return lambda x: x**n
>
> ?
>
> --
> Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list