Functional style programming in python: what will you talk about if you have an hour on this topic?

Carl Banks pavlovevidence at gmail.com
Thu Jul 14 11:04:01 CEST 2011


On Wednesday, July 13, 2011 5:39:16 AM UTC-7, Anthony Kong wrote:
[snip]
> I think I will go through the following items:
> 
> itertools module
> functools module
> concept of currying ('partial')
> 
> 
> I would therefore want to ask your input e.g.
> 
> Is there any good example to illustrate the concept? 
> What is the most important features you think I should cover?
> What will happen if you overdo it?

Java is easily worst language I know of for support of functional programming (unless they added delegates or some other tacked-on type like that), so my advice would be to keep it light, for two reasons:

1. It won't take a lot to impress them
2. Too much will make them roll their eyes

Thinking about it, one of the problems with demonstrating functional features is that it's not obvious how those features can simplify things.  To get the benefit, you have to take a step back and redo the approach somewhat.

Therefore, I'd recommend introducing these features as part of a demo on how a task in Python can be solved much more concisely than in Java.  It's kind of an art to find good examples, though.  Off the top of my head, I can think of using functools module to help with logging or to apply patches, whereas in Java they'd have to resort to a code weaver or lots of boilerplate.


Carl Banks



More information about the Python-list mailing list