Python functional programming

This entry is part 4 of 19 in the series Programming Languages

This article is a work in progress: it will be expanded by your comments…

Python is a very curios programming languages: it give you classes but also a strong function-oriented environment to play with. So, if you like functional programming (read: you like  Lisp and/or Erlang)  you should give python a closer look.

Python offer a huge set of feature previously available only on functional programming languages, like:

  1. Dynamic definition of function/inner classes on the fly. This feature has been extended to compete with highly dinamic languages like ruby
  2. Generator expressions
  3. List comprehensions
  4. Lambda functions

The itertools package (since Python 2.3) give you the ability to easily combine the generator functions.

List comprehensions was considered a powerful feature when introduced inside Erlang: and you get for free on python!

To give an hint of this power, I suggest you some interesting stuff like

Dynamic definition of function/inner classes on the fly. This feature has been extended to compete with highly dinamic languages like ruby

Series NavigationErlang Book ReviewJRuby and Jython: the easy way

Leave a Reply