Nested generators is the python equivalent of unix pipe cmds.

Alex Martelli aleaxit at yahoo.com
Mon Aug 6 12:50:29 EDT 2001


"Tim Hochberg" <tim.hochberg at ieee.org> wrote in message
news:ssya7.78137$Cy.11439637 at news1.rdc1.az.home.com...
    ...
> Although I do think it would be easier to read if the order of the test
and
> the generator was reversed:
>
> for f in Count(20, Test(isGif,  Files('.'))): print f

Agreed, but please don't spell it 'Count' -- 'take(20, whatever)' appears
to me the 'obviously right way' to express "take the first 20 items of
whatever" (Haskell...), while 'count' (in whatever case) suggests to me
a function that counts things (and returns the number it has counted)...


Alex






More information about the Python-list mailing list