A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-February/060381.html below:

[Python-Dev] any support for a methodcaller HOF?

[Python-Dev] any support for a methodcaller HOF? [Python-Dev] any support for a methodcaller HOF?Nick Coghlan ncoghlan at gmail.com
Sat Feb 4 03:18:11 CET 2006
Bengt Richter wrote:
> On Fri, 03 Feb 2006 20:44:47 +1000, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>     funcTakingCallback(x.method(zip, zop) def (x))
>>
>> Consider these comparisons:
>>
> This looks a lot like the "anonymous def" expression in a postfix form ;-)

If you think about the way a for-loop statement maps to the looping portion of 
a listcomp or genexp, or the way an if statement maps to a conditional 
expression, you might notice that this is *not* a coincidence :)

   def g(_seq):
     for x in _seq:
       yield x*x
   g = g(seq)

=> g = (x*x for x in seq)


   l = []
   for x in seq:
     l.append(x*x)

=> l = [x*x for x in seq]

   if cond:
     val = x
   else:
     val = y

=> val = x if cond else y


In all three of the recent cases where a particular usage of a statement has 
been converted to an expression, the variable portion of the innermost part of 
the the first suite is pulled up and placed to the left of the normal 
statement keyword. A bracketing syntax is used when the expression creates a 
new object. All I'm suggesting is that a similarly inspired syntax is worth 
considering when it comes to deferred expressions:

   def f(x):
     return x*x

=> f = (x*x def (x))

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4