[Image-SIG] Scaling image pixels by a variable amount.

Terry Hancock hancock@anansispaceworks.com
Sun, 03 Mar 2002 22:44:36 -0800


Fredrik Lundh wrote:
> > But this doesn't work -- lambda defines a function, and
> > therefore a new name space -- and remember that Python
> > namespaces do not nest!

> they do, in 2.2 and later -- and in 2.1, if you switch
> it on:

> http://www.python.org/doc/2.1.2/ref/nested-scopes.html

That's interesting to know. This is actually the first
time I ever had to worry about it!

> before 2.2, the standard pydiom was to explicitly bind the
> value to an argument:

>     def return_scaled_image(S):
>         return im.point( lambda x, S=S: x * S )

Thanks. Actually someone pointed this out to me off list.
I don't regret the educational experience of doing it
the other way though.

Thanks,
Terry

-- 
------------------------------------------------------
Terry Hancock
hancock@anansispaceworks.com       
Anansi Spaceworks                 
http://www.anansispaceworks.com 
P.O. Box 60583                     
Pasadena, CA 91116-6583
------------------------------------------------------