• Complain

Mertz David. - Functional Programming in Python

Here you can read online Mertz David. - Functional Programming in Python full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Mertz David. Functional Programming in Python
  • Book:
    Functional Programming in Python
  • Author:
  • Genre:
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Functional Programming in Python: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Functional Programming in Python" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

OReilly Media, 2015 - 47 pages; ISBN-13: 978-1-491-92856-1; . .Book Description
Python is not a functional programming language, but it is a multi-paradigm language that makes functional programming easy to perform, and easy to mix with other programming styles. In this paper, David Mertz, a director of Python Software Foundation, examines the functional aspects of the language and points out which options work well and which ones you should generally decline.Mertz describes ways to avoid Pythons imperative-style flow control, the nuances of callable functions, how to work lazily with iterators, and the use of higher-order functions. He also lists several third-party Python libraries useful for functional programming.Topics include:Using encapsulation and other means to describe what a data collection consists of, rather than how to construct a data collection
Creating callables with named functions, lambdas, closures, methods of classes, and multiple dispatch
Using Pythons iterator protocol to accomplish the same effect as a lazy data structure
Creating higher-order functions that take functions as arguments and/or produce a function as a resultTable Of Contents
Preface
(Avoiding) Flow Control
Callables
Lazy Evaluation
Higher-Order Functions

Mertz David.: author's other books


Who wrote Functional Programming in Python? Find out the surname, the name of the author of the book and a list of all author's works by series.

Functional Programming in Python — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Functional Programming in Python" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Functional Programming in Python

by David Mertz

Copyright 2015 OReilly Media, Inc. All rights reserved.

Attribution-ShareAlike 4.0 International (CC BY-SA 4.0).

See: http://creativecommons.org/licenses/by-sa/4.0/

Printed in the United States of America.

Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.

OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .

  • Editor: Meghan Blanchette
  • Production Editor: Shiny Kalapurakkel
  • Proofreader: Charles Roumeliotis
  • Interior Designer: David Futato
  • Cover Designer: Karen Montgomery
May 2015: First Edition
Revision History for the First Edition
  • 2015-05-27: First Release

The OReilly logo is a registered trademark of OReilly Media, Inc. Functional Programming in Python, the cover image, and related trade dress are trademarks of OReilly Media, Inc.

While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.

978-1-491-92856-1

[LSI]

Preface
What Is Functional Programming?

Wed better start with the hardest question: What is functionalprogramming (FP), anyway?

One answer would be to say that functional programming is what you dowhen you program in languages like Lisp, Scheme, Clojure, Scala,Haskell, ML, OCAML, Erlang, or a few others. That is a safe answer, butnot one that clarifies very much. Unfortunately, it is hard to get aconsistent opinion on just what functional programming is, even fromfunctional programmers themselves. A story about elephants and blind menseems apropos here. It is also safe to contrast functional programmingwith imperative programming (what you do in languages like C, Pascal,C++, Java, Perl, Awk, TCL, and most others, at least for the most part).Functional programming is also not object-oriented programming (OOP),although some languages are both. And it is not Logic Programming (e.g.,Prolog), but again some languages are multiparadigm.

Personally, I would roughly characterize functional programming ashaving at least several of the following characteristics. Languages thatget called functional make these things easy, and make other thingseither hard or impossible:

  • Functions are first class (objects). That is, everything you can dowith data can be done with functions themselves (such as passing afunction to another function).

  • Recursion is used as a primary control structure. In some languages,no other loop construct exists.

  • There is a focus on list processing (for example, it is the source of the name Lisp).Lists are often used with recursion on sublists as a substitute forloops.

  • Pure functional languages eschew side effects. This excludes thealmost ubiquitous pattern in imperative languages of assigning firstone, then another value to the same variable to track the program state.

  • Functional programming either discourages or outright disallowsstatements, and instead works with the evaluation of expressions (inother words, functions plus arguments). In the pure case, one program isone expression (plus supporting definitions).

  • Functional programming worries about what is to be computed ratherthan how it is to be computed.

  • Much functional programming utilizes higher order functions (inother words, functions that operate on functions that operate onfunctions).

Advocates of functional programming argue that all these characteristicsmake for more rapidly developed, shorter, and less bug-prone code.Moreover, high theorists of computer science, logic, and math find it alot easier to prove formal properties of functional languages andprograms than of imperative languages and programs. One crucial conceptin functional programming is that of a pure functionone that always returns the same result given the same argumentswhich is more closely akin to the meaning of function in mathematics than that in imperative programming.

Python is most definitely not a pure functional programminglanguage; side effects are widespread in most Python programs. That is,variables are frequently rebound, mutable data collections often changecontents, and I/O is freely interleaved with computation. It is also noteven a functional programming language more generally. However, Pythonis a multiparadigm language that makes functional programming easy todo when desired, and easy to mix with other programming styles.

Beyond the Standard Library

While they will not be discussed withing the limited space of thisreport, a large number of useful third-party Python libraries forfunctional programming are available. The one exception here is that Iwill discuss Matthew Rocklinsmultipledispatchas the best current implementation of the concept it implements.

Most third-party libraries around functional programming are collectionsof higher-order functions, and sometimes enhancements to the tools forworking lazily with iterators contained in itertools. Some notableexamples include the following, but this list should not be taken asexhaustive:

  • pyrsistentcontains a number of immutable collections. All methods on a datastructure that would normally mutate it instead return a new copy of thestructure containing the requested updates. The original structure isleft untouched.

  • toolz provides a set ofutility functions for iterators, functions, and dictionaries. Thesefunctions interoperate well and form the building blocks of common dataanalytic operations. They extend the standard libraries itertools andfunctools and borrow heavily from the standard libraries ofcontemporary functional languages.

  • hypothesis is alibrary for creating unit tests for finding edge cases in your code youwouldnt have thought to look for. It works by generating random datamatching your specification and checking that your guarantee still holdsin that case. This is often called property-based testing, and waspopularized by the Haskell library QuickCheck.

  • more_itertoolstries to collect useful compositions of iterators that neitheritertools nor the recipes included in its docs address. Thesecompositions are deceptively tricky to get right and this well-craftedlibrary helps users avoid pitfalls of rolling them themselves.

Resources

There are a large number of other papers, articles, and books writtenabout functional programming, in Python and otherwise. The Pythonstandard documentation itself contains an excellent introduction calledFunctional Programming HOWTO, by Andrew Kuchling, that discusses some of themotivation for functional programming styles, as well as particularcapabilities in Python.

Mentioned in Kuchlings introduction are several very old public domainarticles this author wrote in the 2000s, on which portions of this reportare based. These include:

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Functional Programming in Python»

Look at similar books to Functional Programming in Python. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Functional Programming in Python»

Discussion, reviews of the book Functional Programming in Python and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.