From: Nobody on
On Tue, 11 May 2010 00:24:22 +1200, Samuel Williams wrote:

> Is Python a functional programming language?

Not in any meaningful sense of the term.

> Is this a paradigm that is well supported by both the language syntax and
> the general programming APIs?

No.

> I heard that lambdas were limited to a single expression,

Yes. In a functional language that wouldn't be a problem, as there's no
limit to the complexity of an expression. Python's expressions are far
more limited, which restricts what can be done with a lambda.

> and that other
> functional features were slated for removal in Python 3... is this the
> case or have I been misinformed?

I don't know about this.

> Finally, even if Python supports functional features, is this a model that
> is used often in client/application code?

Not really. List comprehensions are probably the most common example of
functional idioms, but again they're limited by Python's rather limited
concept of an expression.

From: Luis M. González on
On 10 mayo, 09:24, Samuel Williams <space.ship.travel...(a)gmail.com>
wrote:
> Dear Friends,
>
> Is Python a functional programming language?
>
> Is this a paradigm that is well supported by both the language syntax and the general programming APIs?
>
> I heard that lambdas were limited to a single expression, and that other functional features were slated for removal in Python 3... is this the case or have I been misinformed?
>
> Finally, even if Python supports functional features, is this a model that is used often in client/application code?
>
> Kind regards,
> Samuel

I'm no expert of functional programming at all, but I read many times
(from famous programmers) that Python is very lisp-like, but with a
more conventional syntax.
For example, Paul Graham and others have some interesting views on
this subject: http://www.prescod.net/python/IsPythonLisp.html

That doesn't mean python can compete with other purely functional
languages, but it's probably as functional as it can be for a more
conventional, multiparadigm language.

Luis
From: Samuel Williams on
Thanks to everyone for their great feedback, it is highly appreciated.

Kind regards,
Samuel
From: Paul Rubin on
Luis M. González <luismgz(a)gmail.com> writes:
> That doesn't mean python can compete with other purely functional
> languages, but it's probably as functional as it can be for a more
> conventional, multiparadigm language.

Ben Lippmeier made the interesting claim that one of the defining
characteristics of functional programming is type systems based on the
Curry-Howard correspondence. By that standard I think even Scheme
(perhaps the grandaddy of functional languages) wouldn't qualify.

I do think of Scheme as a functional language, but of Python and Lisp as
imperative languages with functional aspects.

I like learnyouahaskell.com if you want to get some exposure to Haskell,
probably the archetypal functional language these days. I've been
fooling with it on and off for the past couple years. I'm still not
convinced that it's that good a vehicle for practical general purpose
software development, but there are some specific areas where it works
out just beautifully. And in terms of the challenges it presents and
the amount I've learned from it, it's one of the most interesting things
I've done as a programmer in as long as I can remember. It really is
mind altering.
From: Lawrence D'Oliveiro on
In message <7xvdavd4bq.fsf(a)ruckus.brouhaha.com>, Paul Rubin wrote:

> Python is a pragmatic language from an imperative tradition ...

I thought the opposite of “functional” was “procedural”, not “imperative”.
The opposite to the latter is “declarative”. But (nearly) all procedural
languages also have declarative constructs, not just imperative ones
(certainly Python does). Presumably an “imperative” language would not.