Functional Python Programming: Use a functional approach to write succinct, expressive, and efficient Python code, 3rd Edition Lott instant download
Functional Python Programming: Use a functional approach to write succinct, expressive, and efficient Python code, 3rd Edition Lott instant download
https://textbookfull.com/product/functional-python-programming-
use-a-functional-approach-to-write-succinct-expressive-and-
efficient-python-code-3rd-edition-lott/
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/
https://textbookfull.com/product/learn-python-programming-a-
beginner-s-guide-to-learning-the-fundamentals-of-python-language-
to-write-efficient-high-quality-code-romano/
https://textbookfull.com/product/functional-programming-in-c-how-
to-write-better-c-code-1st-edition-enrico-buonanno/
Function Python programming discover the power of
functional programming generator functions lazy
evaluation the built in itertools library and monads
Second Edition Lott
https://textbookfull.com/product/function-python-programming-
discover-the-power-of-functional-programming-generator-functions-
lazy-evaluation-the-built-in-itertools-library-and-monads-second-
edition-lott/
https://textbookfull.com/product/a-functional-approach-to-java-
augmenting-object-oriented-java-code-with-functional-
principles-1st-edition-ben-weidig/
https://textbookfull.com/product/python-projects-for-beginners-a-
ten-week-bootcamp-approach-to-python-programming-milliken/
https://textbookfull.com/product/teach-your-kids-to-code-a-
parent-friendly-guide-to-python-programming-1st-edition-bryson-
payne/
https://textbookfull.com/product/effective-python-90-specific-
ways-to-write-better-python-2nd-edition-brett-slatkin/
Functional Python
Programming
Third Edition
Steven F. Lott
BIRMINGHAM—MUMBAI
“Python” and the Python logo are trademarks of the Python Software Foundation.
Functional Python Programming
Third Edition
Copyright © 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information
presented. However, the information contained in this book is sold without warranty, either express
or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held
liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and
products mentioned in this book by the appropriate use of capitals. However, Packt Publishing
cannot guarantee the accuracy of this information.
Python is an incredibly versatile language that offers a lot of perks for just about every
group. For the object-oriented programming fans, it has classes and inheritance. When
we talk about functional programming, it has functions as a first-class type, higher-order
functions such as map and reduce, and a handy syntax for comprehensions and generators.
Perhaps best of all, it doesn’t force any of those on the user – it’s still totally OK to write a
script in Python without a single class or function and not feel guilty about it.
Thinking in terms of functional programming, having in mind the goals of minimizing state
and side effects, writing pure functions, reducing intermediary data, and what depends on
what else will also allow you to see your code under a new light. It’ll also allow you to
write more compact, performant, testable, and maintainable code, where instead of writing
a program to solve your problem, you “write the language up”, adding new functions to
it until expressing the solution you designed is simple and straightforward. This is an
extremely powerful mind shift – and an exercise worth doing. It’s a bit like learning a
new language, such as Lisp or Forth (or German, or Irish), but without having to leave the
comfort of your Python environment.
Not being a pure functional language has its costs, however. Python lacks many features
functional languages can use to provide better memory efficiency and speed. Python’s
strongest point remains its accessibility – you can fire up your Python interpreter and
start playing with the examples in this book right away. This interactive approach allows
exploratory programming, where you test ideas easily, and only later need to incorporate
them into a more complex program (or not – like I said, it’s totally OK to write a simple
script).
This book is intended for people already familiar with Python. You don’t need to know
much about functional programming – the book will guide you through many common
approaches, techniques, and patterns used in functional programming and how they can
be best expressed in Python. Think of this book as an introduction – it’ll give you the basic
tools to see, think, and express your ideas in functional terms using Python.
Ricardo Bánffy
Steven has been working with Python since the ‘90s, building a variety of tools and
applications. He’s written a number of titles for Packt Publishing, include Mastering
Object-Oriented Python, Modern Python Cookbook, and Functional Python Programming.
He’s a technomad, and lives on a boat that’s usually located on the east coast of the US. He
tries to live by the words, “Don’t come home until you have a story.”
About the reviewers
Alex Martelli is a Fellow of the Python Software Foundation, a winner of the Frank
Willison Memorial Award for contributions to the Python community, and a top-page
reputation hog on Stack Overflow. He spent 8 years with IBM Research, then 13 years
at Think3 Inc., followed by 4 years as a consultant, and lately 17 years at Google. He
has taught programming languages, development methods, and numerical computing at
Ferrara University and other venues.
Books he has authored or co-authored include two editions of Python Cookbook, four
editions of Python in a Nutshell, and a chapter in Beautiful Teams. Dozens of his interviews
and tech talks at conferences are available on YouTube. Alex’s proudest achievement are
the articles that appeared in Bridge World (January and February 2000), which were hailed
as giant steps towards solving issues that had haunted contract bridge theoreticians for
decades, and still get quoted in current bridge-theoretical literature.
Tiago Antao has a BEng in Informatics and a PhD in Life Sciences. He works in the
Big Data space, analyzing very large datasets and implementing complex data processing
algorithms. He leverages Python with all its libraries to carry out scientific computing and
data engineering tasks. He also uses low-level programming languages like C, C++, and
Rust to optimize critical parts of algorithms. Tiago develops on an infrastructure based on
AWS, but has used on-premises computing and scientific clusters for most of his career.
While he currently works in industry, he also has exposure to the academic side of scientific
computing, with two data analysis postdocs at the universities of Cambridge and Oxford,
and a research scientist position at the University of Montana, where he set up, from
scratch, the scientific computing infrastructure for the analysis of biological data.
Preface xxi
ESCENA XVI
(Paulo en el monte.)
Música celeste
en los aires suena,
y, a lo que diviso,
dos ángeles llevan
una alma gloriosa
a la excelsa esfera,
¡Dichosa mil veces,
alma, pues hoy llegas
donde tus trabajos
fin alegre tengan!
Grutas y plantas agrestes,
a quien el hielo corrompe,
¿no veis cómo el cielo rompe
ya sus cortinas celestes?
Ya rompiendo densas nubes
y esos transparentes velos,
alma, a gozar de los cielos
feliz y gloriosa subes.
Ya vas a gozar la palma
que la ventura te ofrece:
¡triste del que no merece
lo que tú mereces, alma!
Muerte me han dado villanos.
ESCENA XIX
(Sale Galván.)
ESCENAS XX y XXI
[El Juez y los villanos armados persiguen a Paulo, el cual, herido, cae
rodando por las peñas. Sale Pedrisco.]
ESCENA XXII
[Los villanos rodean el cadáver de Paulo. Descúbrese fuego, y Paulo
lleno de llamas.]
JORNADA PRIMERA
Sala en el alcázar de Toledo.
ESCENA I
El infante don Enrique, el infante don Juan, don Diego de Haro.
ESCENA II
La reina doña María, de viuda; don Enrique, don Juan, don Diego.
Reina. ¿Qué es aquesto, caballeros,
defensa y valor de España,
espejos de lealtad,
gloria y luz de las hazañas?
Cuando muerto el rey don Sancho,
mi esposo y señor, las galas
truecan León y Castilla
por jergas negras y bastas;
cuando el moro granadino
moriscos pendones saca
contra el reino sin cabeza,
y las fronteras asalta
por la lealtad defendidas,
y abriéndose su Granada,
por las católicas vegas
blasfemos granos derrama;
¡en civiles competencias,
pretensiones mal fundadas,
bandos que la paz destruyen,
ambiciosas arrogancias,
cubrís de temor los reinos,
tiranizáis vuestra patria,
dando en vuestra ofensa lenguas
a las naciones contrarias!
¡Ser mis esposos queréis,
y como mujer ganada
en buena guerra, al derecho
me reducís de las armas!
¡Casarme intentáis por fuerza,
e ilustrándoos sangre hidalga,
la libertad de mi gusto
hacéis pechera y villana!
· · · · · · · · · · · · · · ·
Os engañáis, caballeros,
que no está desamparada
de estos reinos la corona,
ni del Rey la tierna infancia.
Don Sancho el Bravo aún no es muerto;
que como me entregó el alma,
en mi pecho se conservan
fieles y amorosas llamas.
Si, porque es el Rey un niño
y una mujer quien le ampara,
os atrevéis ambiciosos
contra la fe castellana,
tres almas viven en mí:
la de Sancho, que Dios haya;
la de mi hijo, que habita
en mis maternas entrañas,
y la mía, en quien se suman
esotras dos: ved si basta
a la defensa de un reino
una mujer con tres almas.
Intentad guerras civiles,
sacad gentes a campaña,
vuestra deslealtad pregonen
contra vuestro Rey las cajas;
que aunque mujer, yo sabré
en vez de las tocas largas
y el negro monjil, vestirme
el arnés y la celada.
Infanta soy de León;
salgan traidores a caza
del hijo de una leona,
que el reino ha puesto en su guarda,
veréis si en vez de la aguja
sabré ejercitar la espada,
y abatir lienzos de muros
quien labra lienzos de Holanda.
· · · · · · · · · · · · · · ·
ESCENAS III a V
[Los pretendientes, al verse rechazados, reúnen sus partidarios y
alzan bandera de rebelión contra el Rey y la Regente. Don Juan busca
el apoyo de los árabes granadinos: don Enrique acude en demanda
de ayuda a su sobrino el Rey de Portugal; don Diego de Haro espera
tropas de Aragón y Navarra.
La Reina llama a sus vasallos a palacio y les presenta al niño
Fernando IV como rey legítimo de Castilla y León; pero mientras les
habla excitándoles a la lealtad, las tropas rebeldes cercan el palacio
y lo toman por asalto. La Reina y su hijo huyen precipitadamente a
León.]
ESCENAS VI a VIII
(En Valencia de Alcántara.)
ESCENA XIII
(Don Luis, con una fuente de plata, y en ella un papel.)
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com