Extending Python Syntax with @

Kyler Laird Kyler at news.Lairds.org
Thu Mar 11 19:01:54 EST 2004


cookedm+news at physics.mcmaster.ca (David M. Cooke) writes:

>The lambda depends on a global variable too (or at least, a variable
>up one scope).

That's quite a significant difference.  The *result* of the lambda
does not depend on a global variable.

>def make_translation_function(GCPs, type, invert=False):
>    if type == 'LSF' and len(GCPs) < 12:
>        # Do lots of time-consuming magic to calculate A, B, ...
>        def LSF_function(x, y):
>            xy = x*y
>            lon = x*A + y*B + xy*C + ...
>            lat = x*G + y*H + xy*I + ...
>            return (lon, lat)
>        return LSF_function

Ah...*that's* what I needed.  I hadn't considered that a defined
function could be passed out of the scope like that.

Thank you.

--kyler



More information about the Python-list mailing list