Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49142 > unrolled thread

Re: Is this PEP-able? fwhile

Started byJoshua Landau <joshua.landau.ws@gmail.com>
First post2013-06-25 10:10 +0100
Last post2013-06-25 10:10 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Is this PEP-able? fwhile Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-25 10:10 +0100

#49142 — Re: Is this PEP-able? fwhile

FromJoshua Landau <joshua.landau.ws@gmail.com>
Date2013-06-25 10:10 +0100
SubjectRe: Is this PEP-able? fwhile
Message-ID<mailman.3805.1372151473.3114.python-list@python.org>
On 24 June 2013 23:50, Chris Angelico <rosuav@gmail.com> wrote:
>
> In more free-form languages, I implement this by simply omitting a line-break:
...
> Python could afford to lose a little rigidity here rather than gain
> actual new syntax:
>
> for i in range(10): if i%3:
>     print(i)
>
> And there you are, the for-if "filtered iteration" model, just by
> relaxing one rule.

Maybe rather:

    for i in range(10); if i%3:
        print(i)


One of the awesomer things about Coffeescript is:

    decorator = (f) -> (args...) -> f(args[0])

Which lets you do stuff like:

    recursive = do -> r = (n) ->
        if n > 0 then n*r(n-1) else 1

instead of:

    def recursive_gen():
        def recursive(n):
            return n*recursive(n-1) if n > 0 else 1
        return recursive
    recursive = recursive_gen()

Of course, Coffeescript has its own quirks.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web