Proposed new syntax
Stephan Houben
stephanh42 at gmail.com.invalid
Tue Aug 22 05:58:17 EDT 2017
Op 2017-08-11, Paul Rubin schreef <no.email at nospam.invalid>:
> I don't think we need this since we have itertools.takewhile:
>
> from operator import gt
> from functools import partial
> from itertools import takewhile
>
> [x + 1 for x in takewhile(partial(gt,5), (0,1,2,999,3,4))]
>
No need for partial and gt.
[x + 1 for x in takewhile((5).__gt__, (0,1,2,999,3,4))]
Basically, Haskell's infix opererator sections can often be
translated into Python by attribute access to the bound method.
Stephan
More information about the Python-list
mailing list