Why functional Python matters

Dave Benjamin ramen at lackingtalent.com
Tue Apr 15 16:40:08 EDT 2003


In article <v9oq71itajkh39 at news.supernews.com>, John Roth wrote:
> I agree completely. I got turned on to the existing functional
> constructs while I was doing a TDD challenge. I managed
> to do that with exactly one if statement and no loops because
> of the functional constructs.

TDD as in "test-driven development"? I'm not really familiar with this.
Got any good URLs to look at?

> However, losing apply() isn't a big deal because there is
> an exactly equivalent construct. I'd hate to see the rest
> of them go away, especially since the (possible) implementation
> of PEP 308 will remove one of the restrictions on lambdas.

You're right, it's not a big deal. I never use apply anymore, since
Python provides a very convenient syntactic-sugaring as a replacement.

But, I still want to point out the fact that this construct is Python-only.
On the other hand, apply can be implemented with nearly identical behavior
in many other languages, if it doesn't exist already.

> Also notice that there are a set of new functional constructs
> in 2.3 alpha.

I assume you're talking about the "itertools" module. I'm very interested in
this module, though I haven't fully grokked it. I like the "starmap" function.

I think it'd be good to have a module called "functional" where the more
unusual functional tools can live, and I know that it's been brought up before.
Polluting the built-ins further is obviously a bad thing for backward
compatability, not to mention the learning curve. But it would at least make
a statement that functional programming is possible and supported in Python.

Take care,
Dave




More information about the Python-list mailing list