Question regarding a recent article on informit.com

Ian Bicking ianb at colorstudy.com
Wed Mar 19 23:03:30 CET 2003


On Wed, 2003-03-19 at 12:50, Ben S wrote:
> "Python now includes iterators, generators, list comprehensions, nested
> scopes, type unification-and complete Unicode compatibility. The older
> functional programming style constructs, such as map, filter, reduce,
> and lambda are deprecated, even if it's unlikely that they will
> disappear. "
> 
> Is this second sentence true, or is that just an opinion from someone
> who favours the imperative style to the functional style? What else
> could have been meant by this?

The alternative to map and filter, list comprehension, is not less
functional, it's just a different style (Haskell-style, as opposed to
Lisp-style).  As a side effect you don't need lambda to use list
comprehension.

That lambda is a black sheep of the language has always been true,
evidenced by the syntax restrictions.  Lambda also is not the same as
functional programming, but just a particular (again Lisp) style of
functional programming.  Because of Python's semantics -- and improved
with nested scoping -- anything you can do with a lambda you can do with
a function definition.  You can still *do* all the functional things
without lambda, but sometimes it might be more difficult.

Whether Python is a functional language is more defined by its library
and conventions -- do you modify objects in-place, or return modified
copies?  From that perspective large portions of Python code are not
functional, but that language changes don't effect that one way or the
other.

  Ian







More information about the Python-list mailing list