[Python-Dev] decorate-sort-undecorate

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Oct 16 01:11:45 EDT 2003

Peter Norvig <pnorvig at google.com>:

>    [Sum: x*x for x in numbers]
>    [Product: Prob_spam(word) for word in email_msg]
>    [Min: temp(hour) for hour in range(24)]
>    [Top(10): humor(joke) for joke in jokes]
>    [Argmax: votes[c] for c in candidates]

Interesting idea, but I'm a bit worried by the enclosing
[], which suggests that a list is being constructed,
whereas in most of your examples the result isn't a

I still think it would be fun if Python had an "up"
operator, so with suitably defined accumulator
objects you could say things like

  total = add up my_numbers
  product = multiply up some_probabilities

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list