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/2003-October/039057.html below:

[Python-Dev] Re: accumulator display syntax

[Python-Dev] Re: accumulator display syntaxNick Coghlan ncoghlan at iinet.net.au
Mon Oct 20 09:22:21 EDT 2003
Alex Martelli strung bits together to say:

> On Monday 20 October 2003 06:44 am, Greg Ewing wrote:
>    ...
> 
>>So, taking the original accumulator display idea, and
>>incorporating some of the ideas that have come up along
>>the way, such as getting rid of the square brackets,
>>how about
>>
>>  sum of x*x for x in xvalues
>>  average of g for g in grades
>>  maximum of f(x, y) for x in xrange for y in yrange
>>  top(10) of humour(joke) for joke in comedy
> 
> 
> Wow.
> 
> I'm speechless.
> 
> [later, having recovered speech] IF (big if) we could pull THAT off, it
> WOULD be well worth making 'of' a keyword (and thus requiring a
> "from __future__ import").  It's SO beautiful, SO pythonic, the only
> risk I can see is that we'd have newbie people coding:
>     sum of the_values
> rather than:
>     sum(the_values)
> or:
>     sum of x for x in the_values

Except, if it was defined such that you wrote:
   sum of [x*x for x in the_values]

then:
   sum of the_values

would actually be a valid expression, and Greg's examples would become:

   sum of xvalues
   average of grades
   maximum of [f(x, y) for x in xrange for y in yrange]
   top(10) of [humour(joke) for joke in comedy]

Either way, that's some seriously pretty executable psuedocode he has happening! 
And a magic method "__of__" that takes a list as an argument might be enough to 
do the trick, too.

Cheers,
Nick.

-- 
Nick Coghlan           |              Brisbane, Australia
ICQ#: 68854767         |               ncoghlan at email.com
Mobile: 0409 573 268   |   http://www.talkinboutstuff.net
"Let go your prejudices,
               lest they limit your thoughts and actions."


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