python3: 'where' keyword

Steven Bethard steven.bethard at gmail.com
Fri Jan 7 13:23:28 EST 2005


Steven Bethard wrote:
> How often is this really necessary?  Could you describe some benefits of 
> this?  I think the only time I've ever run into scoping problems is with 
> lambda, e.g.
> 
>     [lambda x: f(x) for x, f in lst]
> 
> instead of
> 
>     [lambda x, f=f: for x, f in lst]

Sorry, bad example, this should have looked something more like:

     [lambda y: f(x, y) for x, f in lst]

...

     [lambda y, x=x, f=f: f(x, y) for x, f in lst]

where you actually need the lambda.

Steve



More information about the Python-list mailing list