Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76773

Re: proposed syntax for multiline anony-functions (hopefully?)

From alex23 <wuwei23@gmail.com>
Newsgroups comp.lang.python
Subject Re: proposed syntax for multiline anony-functions (hopefully?)
Date 2014-08-22 15:15 +1000
Organization A noiseless patient Spider
Message-ID <lt6jlm$ddd$1@dont-email.me> (permalink)
References <1bd05b41-ad00-4ce8-8678-de51205ebc3b@googlegroups.com> <913e5a30-f89b-4e94-afb4-b3d302ed44ac@googlegroups.com> <871tsajiqb.fsf@elektro.pacujo.net> <e49beff9-866b-4785-94fa-16122f9a8c1a@googlegroups.com>

Show all headers | View raw


On 21/08/2014 7:30 PM, icefapper@gmail.com wrote:
> On Thursday, August 21, 2014 2:27:08 AM UTC-7, Marko Rauhamaa wrote:
>> In practice, your proposal would not make life easier for Python
>> programmers.
>
> neither did the lambda, yours truly supposes?

alex23 disagrees. alex23 finds the lambda extremely convenient for 
things like sort, filter etc where alex23 wants to provide a function.

alex23 finds this to be very readable:

     odds_list = filter(lambda x: bool(x % 2), some_list)

By comparison, alex23 finds this to be more cumbersome for little gain:

     def odds_only(x):
         return bool(x % 2)
     odds_list = filter(odds_only, some_list)

alex23 finds most examples for multiline anonymous functions to be far 
more difficult to parse than the both restricted lambda form and the 
separate function approach:

     odds_list = filter((def(x):
         return bool(x % 2)), some_list)

alex23 isn't even sure if that's the correct format for your proposed 
syntax, or whether `, some_list)` has to appear on a separate line, or 
even if the () around the anonymous function is even necessary (alex23 
assumed it was from your description of the closing parenthesis popping 
the "space-sensitivity-stack").

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 00:55 -0700
  Re: proposed syntax for multiline anony-functions (hopefully?) Chris Angelico <rosuav@gmail.com> - 2014-08-21 18:18 +1000
    Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 01:59 -0700
      Re: proposed syntax for multiline anony-functions (hopefully?) Chris Angelico <rosuav@gmail.com> - 2014-08-21 19:05 +1000
    Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:06 -0700
    Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:27 -0700
  Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:14 -0700
    Re: proposed syntax for multiline anony-functions (hopefully?) Marko Rauhamaa <marko@pacujo.net> - 2014-08-21 12:27 +0300
      Re: proposed syntax for multiline anony-functions (hopefully?) icefapper@gmail.com - 2014-08-21 02:30 -0700
        Re: proposed syntax for multiline anony-functions (hopefully?) alex23 <wuwei23@gmail.com> - 2014-08-22 15:15 +1000
    Re: proposed syntax for multiline anony-functions (hopefully?) Terry Reedy <tjreedy@udel.edu> - 2014-08-21 06:07 -0400
  Re: proposed syntax for multiline anony-functions (hopefully?) Travis Griggs <travisgriggs@gmail.com> - 2014-08-22 13:05 -0700
    Re: proposed syntax for multiline anony-functions (hopefully?) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-23 19:20 +1000
  Re: proposed syntax for multiline anony-functions (hopefully?) Dan Stromberg <drsalists@gmail.com> - 2014-08-22 16:48 -0700
  Re: proposed syntax for multiline anony-functions (hopefully?) Dan Stromberg <drsalists@gmail.com> - 2014-08-22 16:58 -0700
    Re: proposed syntax for multiline anony-functions (hopefully?) Marko Rauhamaa <marko@pacujo.net> - 2014-08-23 10:37 +0300

csiph-web