Is this PEP-able? fwhile
Joshua Landau
joshua.landau.ws at gmail.com
Tue Jun 25 05:10:30 EDT 2013
On 24 June 2013 23:50, Chris Angelico <rosuav at 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.
More information about the Python-list
mailing list