From: Samuel Williams on
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

From: Stefan Behnel on
Samuel Williams, 10.05.2010 14:24:
> Is Python a functional programming language?

No. Python is a multi-paradigm language. But it does have functions (and
methods) as first-class objects.


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

I'd say so, but it certainly depends on what functional language features
you desire.


> I heard that lambdas were limited to a single expression

.... which is a good thing. An expression in Python can do pretty complex
things already. Not allowing more puts a limit to code readability degradation.


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

No such functionality has been removed in Py3, and in fact, several core
language features were adapted to make functional programming easier and
more efficient.


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

From my point of view, yes. But the beauty is that Python is
multi-paradigm, so you're not restricted to functional language features.

Stefan

From: Bruno Desthuilliers on
Samuel Williams a �crit :
> Dear Friends,
>
> Is Python a functional programming language?

Depends on your definition of "functional programming language", but
well, not really. It's mostly an imperative, object-oriented (but not
pure-object) language. It has some restricted support for some
functional idioms but trying to use it a true FPL would be a waste of
time (both developper's and computer's).

> 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,

True.

> and that other functional features were slated for removal in Python 3...

False.

Some FP-inspired functions and types are moving from builtins to a
dedicated module, but they are still available.

> 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?

Once again, depends on your definitions of what's "functional". Some
FP-inspired idioms and features are definitly idiomatic, but that
doesn't make for true functional programming. Once again, trying to do
pure FP in Python would be fighting against the language.



From: Paul Rubin on
Samuel Williams <space.ship.traveller(a)gmail.com> writes:
> Is Python a functional programming language?

It supports some aspects of functional programming but I wouldn't go as
far as to call it an FPL.

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

I'd say "somewhat supported" rather than "well supported".

> 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?

I think, some features were slated for removal, but after some
discussion they were moved to libraries instead of eliminated
completely.

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

That's more a question of the programmers than the programs. If you're
comfortable programming in functional style, that will tend to show
up in your python code. There are some contortions you have to do though.

If your goal is to engage in functional programming, you're better off
using a language designed for that purpose. Python is a pragmatic
language from an imperative tradition, that has some functional features
tacked on. Python is pleasant for imperative programming while letting
you make some use of functional style.
From: Aahz on
In article <7xvdavd4bq.fsf(a)ruckus.brouhaha.com>,
Paul Rubin <no.email(a)nospam.invalid> wrote:
>
>If your goal is to engage in functional programming, you're better off
>using a language designed for that purpose. Python is a pragmatic
>language from an imperative tradition, that has some functional features
>tacked on.

While your first sentence is spot-on, saying that functional features
are "tacked on" understates the case. Consider how frequently people
reach for list comps and gen exps. Function dispatch through dicts is
the standard replacement for a switch statement. Lambda callbacks are
common. Etc, etc, etc
--
Aahz (aahz(a)pythoncraft.com) <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.