Key FeaturesImplement common functional programming design patterns and techniques in PythonLearn how to choose between imperative and functional approaches based on expressiveness, clarity, and performanceApply functional Python to common Exploratory Data Analysis (EDA) programming problemsBook DescriptionPython’s easy-to-learn and extensible abilities offer a number of functional programming features for you to bring into your workflow, especially in the realm of data science.
If you’re a Python developer who wants to discover how to take the power of functional programming and bring it into your own programs then this book is essential for you, even if you know next to nothing about the paradigm. Starting with a general overview of functional concepts you’ll explore common functional features such as first-class and higher-order functions, pure functions and more, and how these are accomplished in Python to give you the core foundations you’ll build upon. After that, you’ll discover common functional optimizations for Python to help your apps reach even higher speeds. You'll also explore data preparation techniques and data exploration in depth, along with learning how the Python standard library fits the functional programming model. Finally, to top off your journey into the world of function Python you’ll at look at the PyMonad project and some larger examples to put everything into perspective.
With Functional Python Programming by your side you’ll understand the core concepts of function Python, its impact on the programming workflow, and how to implement it in Python, giving you the ability to take your applications to an even higher level.
What you will learnUse Python's generator functions and generator expressions to work with collections in a non-strict (or lazy) mannerUtilize Python library modules including itertools, functools, multiprocessing, and concurrent.futures for efficient functional programsUse Python strings with object-oriented suffix notation and prefix notationAvoid stateful classes by making use of families of tuplesDesign and implement decorators to create composite functionsUse functions like max(), min(), map(), filter(), and sorted()Write advanced higher-order functionsAbout the AuthorSteven F. Lott has been programming since the 70s, when computers were large, expensive, and rare. As a contract software developer and architect, he has worked on hundreds of projects, from very small to very large. He's been using Python to solve business problems for over 10 years.
Table of ContentsIntroducing Functional ProgrammingIntroducing Some Functional FeaturesFunctions, Iterators, and GeneratorsWorking with CollectionsHigher-order FunctionsRecursions and ReductionsAdditional Tuple TechniquesThe Itertools ModuleMore Itertools TechniquesThe Functools ModuleDecorator Design TechniquesThe Multiprocessing and Threading ModulesConditional Expressions and the Operator ModuleThe Pymonad LibraryA Functional Approach to Web ServicesOptimizations and Improvements
Another book the proves my theory that the quality of a book is inversely proportional to the amount of "as follows".
But functional programming in Python is generators.
That's it: Generators. Oh, generators and tuples.
There is a lot in this book, but mostly seems... wrong. For example, talking about "tail call optimization", when Python does not have them. And then talking how to optimize those -- which, again, it is plain "replace with a generator".
Also, the case for tuples is that namedtuples is mentioned, but rarely used. This makes code hard to read, except the author decided to create lambdas to extract them, so you end up with a bunch of xy_g = lambda p: p[0][1][0]. What the fuck is 0, 1 and 0 again in this? Why not use name tuples and, instead of this atrocity, go with p.position.x?
Other examples of wrong things:
- "extract the docstring function": Doctstrings are strings, not functions. - "GNU Image Manipulation Program (GIMP) GNU General Public License (GPL) file format": Neither GIMP not GPL is a file format; one is a photo editor and the other is a license. - "This is relatively simple implementation copied from the World Wide Web": And we all know how things on the web are reliant. - "We can use ((line.split() for line in file) to create a sequence of ten tuples": First of all, yes, the there is some unbalanced parenthesis there; second, that thing won't generate ten tuples, it will generate as many as the lines in the file -- which is never shown, by the way. - Calling functions that return generators "higher-order functions". And no, the function does not receive a function, it simply returns a generator. - "perms = permutations(range(6)))))". Yup, there are 4 extra closing parenthesis. - Splitting a string with a path in it by /, then checking the first value instead of, say, path.startswith('expected_value'). - "We've created a Counter() function": Counter is a class, not a function. - Lots of "not clear if this is helpful". Ok, showing some sort of code is ok, but not explaining where if it is useful -- or if it is useful at all -- is plain... lazy. - "We've shown the loop here to clarify that the server must, generally, be crashed": It's the first time that I see that we expect a server to be crashed. - There is a convoluted aggregation grouping things in a dictionary with a key and a count, and then using Counter() to check the number of times something appear. Problem is, when Counter() process the dict, it will get only the keys, so the whole process of generating the dictionary is completely useless. - By the end of the book, I'm not sure if things are being double double-quoted (as in ""this is string"") or quadruple single-quote (''''this is string'''') -- but neither format is valid Python.
Besides all that, there is a bunch of explanations that are very much akin to
a = a + 1
Adds 1 to a.
Also, there are chapters for multiprocessing, which has absolutely nothing functional about it and WSGI, which, again, has nothing functional about it.
The whole book feels rushed and badly reviewed -- if reviewed before publishing at all.
I was one of the reviewers for this book prior to publishing, and found it to be a well thought out, comprehensive approach to functional programming. The only point where it fell short (to around a half star) was that it could be a bit longer, something I'm positive will be fixed in another edition :)
I haven't finished reading it (though, I don't need to). I might use it as a reference, but I am a bit disappointed by the example with generators, which seemed to be broken when I tested it. I think a book is supposed to provide details in a simple manner. That's when you can trust the source you are reading. There are many details in the book which I needed to skip. There are things which I would have liked to be discussed, like semaphores, mutex, locks, rlock, conditions, events and the differences for each of them and when to use one over the other and things like that.
Intro-level coverage of functional programming concepts, and lots of Python examples.
I learned some cool tips & tricks with Python syntax. Wasn't too dense, and felt easy to follow. The author does a good job of both explaining and pacing.
Worth a read for anyone interested in FP and Python.
This book is not very easy for beginners. But the author really explained the techniques in functional programming. Those who read the book throughly definitely will learn some useful things from the author. I plan to read it again in two weeks.
not very systematic book. More like a introduction about "how to use XXX ..". Still good to help you build a notion that you could do it in functional way in python if you remember XXX
Good exposure to Python's functional tools. What I didn't like so much was 1. the examples: they were totally number crunching related for no reason. I mean, GPS data crunching as an example? Nothing better could be found? 2. The explanation about functional concepts. Especially monads are described as something totally simple which is not needed in python.
A good book if you are starting with Functional Programming and Python is the language that you use. The content is good and so is the coverage. I would rate it slightly higher than 4 stars