a = b = 1 just syntactic sugar?

Steven Taschuk staschuk at telusplanet.net
Sat Jun 7 18:26:01 CEST 2003


Quoth Ed Avis:
> Steven Taschuk <staschuk at telusplanet.net> writes:
  [...]
> >I'm not sure I understand the difficulty; I'd be interested to see
> >an example of the code you wanted to write but couldn't.
> 
> On second thoughts I think it was a kind of unification that would
> return a function to turn x into y, or return None if x and y could
> not be unified.
  [example]
> (Note: I don't claim this is some general unification algorithm, it is
> one-sided and in any case just an example.)  [...]

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

Still broken, for reasons you mention, but the restrictions on
lambda seem a little irrelevant.  If they bite you, just use def.

-- 
Steven Taschuk                                     staschuk at telusplanet.net
Receive them ignorant; dispatch them confused.  (Weschler's Teaching Motto)





More information about the Python-list mailing list