a = b = 1 just syntactic sugar?

Ed Avis ed at membled.com
Mon Jun 9 02:47:23 EDT 2003


martin at v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=) writes:

>For example, what is the meaning of
>
>a = lambda b : return b > 0

I propose it to mean the same as

    def fresh(b):
      return b > 0
    a = fresh

where 'fresh' is a newly generated symbol.

In the cases where the body of the lambda-function is an
expression_stmt (for example 'b > 0' with no 'return') I propose to
make the meaning the same as today's lambda-functions.
    
>x = lambda b:c=3
>
>what happens if I invoke x(4)?

Just the same as what happens with

    def fresh(b):
      c=3
    x = fresh
    x(4)

>What if x is
>
>x = lambda c:c=3
>
>What is the meaning of continue inside lambda?

Again, the meaning is just the same as a named function definition
with the same body.  (It would be interesting do let 'continue' and
'break' and maybe 'return' inside lambda have meanings that affect the
control flow of the calling routine, but that is not part of my
proposal.)

-- 
Ed Avis <ed at membled.com>




More information about the Python-list mailing list