parameterized functions: a question of style

Blair Hall b.hall at
Tue Aug 13 00:56:47 CEST 2002


I agree, but my example was hypothetical (I didn't want to write a
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,

More information about the Python-list mailing list