[Python-Dev] accumulator display syntax

Alex Martelli aleaxit at yahoo.com
Thu Oct 16 07:56:35 EDT 2003

On Thursday 16 October 2003 01:38 pm, Paul Svensson wrote:
> On Thu, 16 Oct 2003, Alex Martelli wrote:
> >I think we could extend indexing to mean something different when
> >the [ ] contain a 'for', just like we extended list display to mean
> >something different (list comprehension) when the [ ] contain a
> >'for'.  Syntax such as:
> >
> >    Top(10)[ humor(joke) for joke in jokes ]
> >
> >does not suggest a list is _returned_, just like foo[23] doesn't.
> But it does immediately suggest
>     iter[humor(joke) for joke in jokes]
> as the format for iterator comprehensions.
> Is that good or bad ?

Personally I consider it very good, because, in my other message about 
"accumulator display semantics", I show exactly how to achieve that by
generalizing the semantics of these displays (well, I show it for a class
Iter, but the built-in iter might perfectly well define an __accum__ special
method and achieve exactly the same effect).


More information about the Python-Dev mailing list