I don't believe Python supports Functional programming, as in Prolog or somesuch. It supports function-based programming... meaning that your program is just composed of functions not organized into classes and objects. I have gotten the two confused in the past, and I suspect that this is what happened here.
Or does Python really support functional programming? Is there some add-on package that allows this? I wasn't aware of one. -- ansible
Yes, Python really does have some built-in functional programming features such as "map()", "filter()", "reduce()" and a somewhat limited "lambda", although I've read that Guido van Rossum now regrets including these features in the language. As a more readable and "Pythonic" alternative, "list comprehensions" were more recently introduced into the language and can often be used instead of the older functional programming constructs.
- I for one do not believe very much in language purity, and I say that as someone who admires Scheme. Fiddly distinctions such as "object-oriented" vs. "object-based", or "functional" vs. "function-based" vs. "pure-functional" are, simply put, religious disputes. As such, they may merit being mentioned in Wikipedia (as do real religious disputes) but should not be taken too seriously.
- I consider functional programming, like object-oriented programming, to be chiefly a style of programming -- i.e. something that programmers do, not something that languages do. A language can allow a style of programming, or can even attempt to mandate its use (e.g. Scheme; Java), but it is the program which has a style not the language. It is in this light which I wrote in the subject article that "Object orientation and structured programming are supported, as well as functional programming."
- (It is possible to write an imperative-style program in the "functional language" Scheme using begin and do, or an object-oriented program in the "structured language" ANSI C. It isn't possible to write a functional program in Pascal, though, since you can't pass around functions.)
- Of course Python does not attempt to be a "pure-functional language" i.e. a language which requires programmers to use functional constructs. Nevertheless, it still permits the style in the large, by (for instance) permitting functions as values, generators, continuations, etc. --FOo
I do not think Python is 'strongly influenced' by Perl. In fact the design philosophy is diametrically opposite in some senses.pasokan
- Let's see -- Python's an interpreted/bytecode-compiled language, with mixed type arrays, garbage collection, hashes/dicts as a basic type, a big standard library with support for Unix calls ... it has a lot in common with Perl. A large portion of the Python user base are "converts" from Perl. Python also self-consciously eschews Perl-like syntax, which is a different way of being "influenced" by Perl! --FOo