Proposed PEP for a Conditional Expression

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Fri Sep 14 15:22:47 EDT 2001


Fri, 14 Sep 2001 11:21:31 -0700, James_Althoff at i2.com <James_Althoff at i2.com> pisze:

> Why not just start with something simple like a builtin "cond" function
> approximating the following:

I don't like prepending 'lambda:' to both alternatives.

    abs = if x>=0 then x else -x
or
    abs = if x>=0: x else: -x
looks more readable than
    abs = cond(x>=0, lambda:x, lambda:-x)
for me.

> ps.  Then attention could be focused on defining a mechanism for
> general-purpose, unnamed, "in-place" code blocks.  If we had such,
> we could then create many convenient idioms using functions and
> methods -- instead of constantly wrangling with new syntactic forms
> and keywords.

Yes, but the syntax of explicitly creating such block would be a bit
annoying if they would have to be created for e.g. loops.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list