My Account Log in

1 option

Functional Python programming : use a functional approach to write succinct, expressive, and efficient Python code / Steven F. Lott ; foreword by Ricardo Banffy.

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Lott, Steven F., author.
Contributor:
B̀nffy, Ricardo, writer of foreword.
Series:
Expert insight.
Expert insight
Language:
English
Subjects (All):
Python (Computer program language).
Functional programming (Computer science).
Physical Description:
1 online resource (576 pages)
Edition:
Third edition.
Place of Publication:
Birmingham : Packt Publishing, [2022]
Summary:
Python isn't all about object-oriented programming. Discover a valuable way of thinking about code design through a function-first approach - and learn when you need to use it. Now with detailed exercises at the end of every chapter! Purchase of the print or Kindle book includes a free eBook in PDF format. Key Features Learn how, when, and why to adopt functional elements in your projects Explore the Python modules essential to functional programming, like itertools and functools Revised to cover new features of Python 3.10, exercises at the end of every chapter, and more Book Description Not enough developers understand the benefits of functional programming, or even what it is. Author Steven Lott demystifies the approach, teaching you how to improve the way you code in Python and make gains in memory use and performance. Starting from the fundamentals, this book shows you how to apply functional thinking and techniques in a range of scenarios, with examples centered around data cleaning and exploratory data analysis. You'll learn how to use generator expressions, list comprehensions, and decorators to your advantage. You don't have to abandon object-oriented design completely, though - you'll also see how Python's native object-orientation is used in conjunction with functional programming techniques. By the end of this book, you'll be well versed in the essential functional programming features of Python, and understand why and when functional thinking helps. You'll also have all the tools you need to pursue any additional functional topics that are not part of the Python language. What you will learn Use Python's libraries to avoid the complexities of state-changing classes Leverage built-in higher-order functions to avoid rewriting common algorithms Write generator functions to create lazy processing Design and implement decorators for functional composition Make use of Python type annotations to describe parameters and results of functions Apply functional programming to concurrency and web services Explore the PyMonad library for stateful simulations Who this book is for The functional paradigm is very useful for programmers working in data science, but any Python developer who wants to create more reliable, succinct, and expressive code will have much to learn from this book. No prior knowledge of functional programming is required to get started, though Python programming knowledge is assumed. A running Python environment is essential.
Contents:
Cover
Copyright
Contributors
Table of Contents
Preface
Chapter 1: Understanding Functional Programming
The functional style of programming
Comparing and contrasting procedural and functional styles
Using the functional paradigm
Using a functional hybrid
The stack of turtles
A classic example of functional programming
Exploratory data analysis
Summary
Exercises
Convert an imperative algorithm to functional code
Convert step-wise computation to functional code
Revise the sqrt() function
Data cleansing steps
(Advanced) Optimize this functional code
Chapter 2: Introducing Essential Functional Concepts
Functions as first-class objects
Pure functions
Higher-order functions
Immutable data
Strict and non-strict evaluation
Lazy and eager evaluation
Recursion instead of an explicit loop state
Functional type systems
Familiar territory
Learning some advanced concepts
Apply map() to a sequence of values
Function vs. lambda design question
Optimize a recursion
Chapter 3: Functions, Iterators, and Generators
Writing pure functions
Functions as first-class objects
Using strings
Using tuples and named tuples
Using generator expressions
Exploring the limitations of generators
Combining generator expressions
Cleaning raw data with generator functions
Applying generators to built-in collections
Generators for lists, dicts, and sets
Using stateful mappings
Using the bisect module to create a mapping
Using stateful sets
Rewrite the some_function() function
Alternative Mersenne class definition
Alternative algorithm implementations
Map and filter
Dictionary comprehension
Raw data cleanup
Chapter 4: Working with Collections
An overview of function varieties
Working with iterables
Parsing an XML file
Parsing a file at a higher level
Pairing up items from a sequence
Using the iter() function explicitly
Extending an iteration
Applying generator expressions to scalar functions
Using any() and all() as reductions
Using len() and sum() on collections
Using sums and counts for statistics
Using zip() to structure and flatten sequences
Unzipping a zipped sequence
Flattening sequences
Structuring flat sequences
Structuring flat sequences
an alternative approach
Using sorted() and reversed() to change the order
Using enumerate() to include a sequence number
Palindromic numbers
Hands of cards
Replace legs() with pairwise()
Chapter 5: Higher-Order Functions
Using max() and min() to find extrema
Using Python lambda forms
Lambdas and the lambda calculus
Using the map() function to apply a function to a collection
Working with lambda forms and map()
Using map() with multiple sequences
Notes:
OCLC-licensed vendor bibliographic record.
ISBN:
9781523151417
1523151412
9781803232577
1803232579
OCLC:
1357496464

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

Find

Home Release notes

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Find catalog Using Articles+ Using your account