A little present.

Michael Hudson mwh21 at cam.ac.uk
Tue Feb 15 09:27:09 EST 2000


"Warren Postma" <embed at geocities.com> writes:

> > Here's one:
> >
> > class Hole:
> >     pass
> 
> 
> Can anyone give me a useful example of WHY you'd want to do this, or is this
> just more weird example of Functional Code-Fu? { If do right, no can
> defend. }

Yes it is a functional style thing, but I only wanted it for
interactive fiddling. There are better solutions for "real" code.

It's a bit like Haskell's "operator sections", which I miss in
Python. They let you do things like:

Prelude> map (`mod` 5) [1..8]
[1,2,3,4,0,1,2,3]

but Haskell is absolutely untouchable for syntactic cuteness.

I even thought about hacking them into Python, but then realised I
don't know how to drive the grammar, and that it was more work then I
could be bothered with.

"fib = 1 : 1 : [ a+b | (a,b) <- zip fib (tail fib) ]"-ly y'rs
Michael



More information about the Python-list mailing list