statements in control structures (Re: Conditional Expressions don't solve the problem)

Christopher A. Craig com-nospam at ccraig.org
Thu Oct 18 10:22:50 EDT 2001


"Anders J. Munch" <andersjm at dancontrol.dk> writes:

> Here's an additional alternative:
> 
> Use a function-like form let to perform assignment within expression.
>   let(X,Y)
> has the effect of doing
>   X = Y
> and returning the assigned object.

I had thought about doing this earlier.  You could do this now with a little
ugly syntax:

def let(a, b):
  a[0] = b
  return a[0]

while let([a], get_next()):
  process(x)


The problem being that you have to pass the variable as an element in a
mutable structure in order to modify it.  The problem with your proposal
being that you don't (and it would be the only function where you don't).

-- 
Christopher A. Craig <com-nospam at ccraig.org>




More information about the Python-list mailing list