a = b = 1 just syntactic sugar?

Ed Avis ed at membled.com
Sat Jun 7 16:44:04 EDT 2003


Steven Taschuk <staschuk at telusplanet.net> writes:

>Ignoring the problems due this just being an example, and
>concentrating just on the question of lambda's restrictions, I
>don't see why you can't just use def:
>
>    def maybe_unify(x, y):
>        if x == y:
>            def change(X):
>                pass
>        elif x == []:
>            def change(X):
>                X.extend(y)
>        else:
>            change = None
>        return change

Yes - I don't know why I didn't think of that.  Thanks for the
suggestion.  Of course it seems a little clunky to define these
functions with a name that is then never used except to return them
anonymously, but it should work.

-- 
Ed Avis <ed at membled.com>




More information about the Python-list mailing list