First draft of Functional HOWTO
I've finally completed a first draft of a Functional Programming HOWTO that discusses the language feature and modules that are useful in functional-style programs. The draft is at <http://www.amk.ca/python/writing/functional>; this won't be its permanent home, because once it's done it'll go in Doc/howto/ in the distribution. I'd greatly appreciate comments on it. It still feels somehow incomplete, like more of the general material is needed, but I'm not sure what to add. I wrote a small but nontrivial functional program as an example -- it's in sandbox/Doc in SVN -- but I'm not sure dissecting an example is very useful. The resulting section would be fairly long, and I haven't come up with an example that exercises every single feature (e.g. most of the \ functions in the itertools module). A more minor issue: perhaps the HOWTO should describe genexps in detail, and mention listcomps as an aside; this would be the oppposite of how it's currently organized. Thoughts? --amk
A.M. Kuchling wrote:
I'd greatly appreciate comments on it. It still feels somehow incomplete, like more of the general material is needed, but I'm not sure what to add.
It reads pretty well to me. One question on the documentation of list comps - is the choice to leave out the fact that you can insert filter expressions at any level in a list comp with multiple for clauses deliberate? The sorting URL needs updating, too: http://wiki.python.org/moin/HowTo/Sorting Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
Hello amk. I've a few comments to your Functional Programming HOWTO. It is only a few typos, the text is really good. Here it goes: 1 - In the code sample below the text "You can figure it out, but it takes time" ... there is: def combine (a, b): return 0, a[1] + b[1] return reduce(combine_freq, items)[1] the first parameter to reduce should read combine, not combine_freq (or the def combine should read def combine_freq), right? 2 - At Small functions and the lambda statement section: "Which alternative is preferable? That's a style question; my general view is to avoid it." I'm not a native english speaker, but, avoiding what? The style question, the def or the lambda? 3 - Below Fredrik Lundh comments about refactoring lambdas: "I really like these rules, but you're free todisagree that this style is better." to disagree. there is a blank space missing. 4 - in the first code sample of the same section: " stripped_lines = [line.strip for line in lines] existing_files = filter(os.path.exists, file_list) " shouldn't it read stripped_lines = [line.strip() for line in lines]? Or you really want a list of "built-in method strip"? That's it. The text is very good! Congratulations. -- Regards Leandro Lameiro Blog: http://lameiro.redirectme.net/blog On 6/30/06, A.M. Kuchling <amk@amk.ca> wrote:
I've finally completed a first draft of a Functional Programming HOWTO that discusses the language feature and modules that are useful in functional-style programs.
The draft is at <http://www.amk.ca/python/writing/functional>; this won't be its permanent home, because once it's done it'll go in Doc/howto/ in the distribution.
I'd greatly appreciate comments on it. It still feels somehow incomplete, like more of the general material is needed, but I'm not sure what to add.
I wrote a small but nontrivial functional program as an example -- it's in sandbox/Doc in SVN -- but I'm not sure dissecting an example is very useful. The resulting section would be fairly long, and I haven't come up with an example that exercises every single feature (e.g. most of the \ functions in the itertools module).
A more minor issue: perhaps the HOWTO should describe genexps in detail, and mention listcomps as an aside; this would be the oppposite of how it's currently organized. Thoughts?
--amk _______________________________________________ Doc-SIG maillist - Doc-SIG@python.org http://mail.python.org/mailman/listinfo/doc-sig
participants (3)
-
A.M. Kuchling -
Leandro Lameiro -
Nick Coghlan